blob: 168f64d9e1cfe537f8f4ec5984cf591f28e61917 (
plain) (
tree)
|
|
---
- name: get ssh keys for all users
ansible.builtin.find:
paths: "{{ sshd__keys_paths }}"
file_type: link
recurse: true
delegate_to: localhost
run_once: true
register: sshd__keys_result_find
- name: set sshd__keys_found_users variable
ansible.builtin.set_fact:
sshd__keys_found_users: "{{ sshd__keys_result_find.files
| map(attribute='path')
| map('dirname')
| map('basename')
| unique }}"
- name: synchronize ssh keys
ansible.posix.authorized_key:
user: "{{ item.path | dirname | basename }}"
state: present
key: "{{ lookup('file', item.path) }}"
loop_control:
label: "{{ item.path }}: {{ item.path | dirname | basename }}"
loop: "{{ sshd__keys_result_find.files }}"
failed_when: false
|