19 lines
592 B
YAML
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 |