Files
ansible-playbooks/deploy-keys/deploy-keys.yaml
2024-02-02 21:24:08 +01:00

19 lines
592 B
YAML

---
- name: Add SSH Keys on Hosts
hosts: all
vars_files:
- vars/public-keys.env
tasks:
- name: Get SSH Keys
ansible.builtin.shell: cat /root/.ssh/authorized_keys
register: key_output
- name: Add SSH Keys
with_items:
- "{{ ssh_keys }}"
ansible.builtin.shell: |
cat <<EOF >> /root/.ssh/authorized_keys
### Managed with Ansible {{ ansible_date_time.day }}-{{ ansible_date_time.month }}-{{ ansible_date_time.year }} ###
{{ item }}
EOF
when: key_output.stdout.find('{{ item }}') == -1