enh: replaced with loop
This commit is contained in:
+4
-4
@@ -9,7 +9,7 @@
|
|||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
groups: "{{ group }},ssh_access"
|
groups: "{{ group }},ssh_access"
|
||||||
password: "{{lookup('password', 'cred.' + item + '.pass chars=ascii_letters,digits,hexdigitsi length=15') | password_hash('sha512')}}"
|
password: "{{lookup('password', 'cred.' + item + '.pass chars=ascii_letters,digits,hexdigitsi length=15') | password_hash('sha512')}}"
|
||||||
with_items: "{{userlist}}"
|
loop: "{{userlist}}"
|
||||||
|
|
||||||
- name: Add user to sudoers
|
- name: Add user to sudoers
|
||||||
lineinfile:
|
lineinfile:
|
||||||
@@ -18,16 +18,16 @@
|
|||||||
line: "{{ item }} ALL=(ALL) NOPASSWD: ALL"
|
line: "{{ item }} ALL=(ALL) NOPASSWD: ALL"
|
||||||
mode: 0440
|
mode: 0440
|
||||||
when: sudoers
|
when: sudoers
|
||||||
with_items: "{{userlist}}"
|
loop: "{{userlist}}"
|
||||||
|
|
||||||
- name: Display generated password
|
- name: Display generated password
|
||||||
debug:
|
debug:
|
||||||
msg: "Generated password for {{item}}: {{lookup('password', 'cred.' + item + '.pass chars=ascii_letters,digits,hexdigitsi length=15')}}"
|
msg: "Generated password for {{item}}: {{lookup('password', 'cred.' + item + '.pass chars=ascii_letters,digits,hexdigitsi length=15')}}"
|
||||||
with_items: "{{userlist}}"
|
loop: "{{userlist}}"
|
||||||
|
|
||||||
- name: Remove password files created by ansible
|
- name: Remove password files created by ansible
|
||||||
file:
|
file:
|
||||||
path: cred.{{item}}.pass
|
path: cred.{{item}}.pass
|
||||||
state: absent
|
state: absent
|
||||||
with_items: "{{userlist}}"
|
loop: "{{userlist}}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user