From 6509316c8c4b4ea7287226d9f06c5017e557925a Mon Sep 17 00:00:00 2001 From: "Ethan N. Paul" Date: Thu, 13 Dec 2018 22:30:40 -0500 Subject: [PATCH] Add task to copy generated keys to repo --- playbooks/update-local-users.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/playbooks/update-local-users.yml b/playbooks/update-local-users.yml index 6e3107c..edb6983 100644 --- a/playbooks/update-local-users.yml +++ b/playbooks/update-local-users.yml @@ -38,9 +38,9 @@ - name: Create local user accounts tags: users_create + become: true block: - name: Create groups - become: true group: name: "{{ item }}" state: present @@ -49,7 +49,6 @@ - omni - name: Create users - become: true user: name: "{{ item.name }}" comment: "{{ item.fullname | default('') }}" @@ -64,6 +63,17 @@ with_items: - "{{ local_users | difference([None]) }}" + - name: Copy new keys + when: generate_keys|bool == true + fetch: + dest: "{{ playbook_dir + '/keys/' + item.name + '/' + inventory_hostname + '.pub' if item.name != 'root' and item.name != 'ansible' else '/dev/null' }}" + flat: yes + fail_on_missing: no + src: /home/{{ item.name }}/.ssh/id_rsa.pub + validate_checksum: no + with_items: + - "{{ local_users | difference([None]) }}" + - name: Delete users that have been removed tags: users_delete block: