blob: 168f64d9e1cfe537f8f4ec5984cf591f28e61917 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
---
- 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
|