diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2022-12-12 22:51:55 +0100 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2022-12-17 17:02:24 +0100 |
commit | 970a107492c31a43bb77f6f5e0096b41adc2c2f4 (patch) | |
tree | 614ee1b08379eb5838aaf004e58f31880127bc9d /roles/sshd_keys/tasks/main.yml | |
parent | db698b595e7ff088c96d00ef5285a0d634aff1be (diff) | |
download | rules-970a107492c31a43bb77f6f5e0096b41adc2c2f4.tar.gz |
refactor: split sshd and ssh key synchronization
Diffstat (limited to 'roles/sshd_keys/tasks/main.yml')
-rw-r--r-- | roles/sshd_keys/tasks/main.yml | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/roles/sshd_keys/tasks/main.yml b/roles/sshd_keys/tasks/main.yml new file mode 100644 index 0000000..32f6b5a --- /dev/null +++ b/roles/sshd_keys/tasks/main.yml @@ -0,0 +1,20 @@ +--- + +- name: get ssh keys for all users + ansible.builtin.find: + paths: files/keys + file_type: link + recurse: true + delegate_to: localhost + run_once: true + register: result + +- 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 }} -> user: {{ item.path | dirname | basename }}" + loop: "{{ result.files }}" + failed_when: false |