Add task to copy generated keys to repo
This commit is contained in:
parent
59aba361ec
commit
6509316c8c
@ -38,9 +38,9 @@
|
|||||||
|
|
||||||
- name: Create local user accounts
|
- name: Create local user accounts
|
||||||
tags: users_create
|
tags: users_create
|
||||||
|
become: true
|
||||||
block:
|
block:
|
||||||
- name: Create groups
|
- name: Create groups
|
||||||
become: true
|
|
||||||
group:
|
group:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
@ -49,7 +49,6 @@
|
|||||||
- omni
|
- omni
|
||||||
|
|
||||||
- name: Create users
|
- name: Create users
|
||||||
become: true
|
|
||||||
user:
|
user:
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
comment: "{{ item.fullname | default('') }}"
|
comment: "{{ item.fullname | default('') }}"
|
||||||
@ -64,6 +63,17 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- "{{ local_users | difference([None]) }}"
|
- "{{ 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
|
- name: Delete users that have been removed
|
||||||
tags: users_delete
|
tags: users_delete
|
||||||
block:
|
block:
|
||||||
|
Reference in New Issue
Block a user