Verify if login exists
This commit is contained in:
parent
94223e54a0
commit
35198325c4
|
@ -1,5 +1,12 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
|
- name: "Test if '{{ user.name }}' exists"
|
||||||
|
command: 'getent passwd {{ user.name }}'
|
||||||
|
register: loginisbusy
|
||||||
|
failed_when: False
|
||||||
|
changed_when: False
|
||||||
|
check_mode: no
|
||||||
|
|
||||||
- name: "Test if uid exists for '{{ user.name }}'"
|
- name: "Test if uid exists for '{{ user.name }}'"
|
||||||
command: 'getent passwd {{ user.uid }}'
|
command: 'getent passwd {{ user.uid }}'
|
||||||
register: uidisbusy
|
register: uidisbusy
|
||||||
|
@ -16,7 +23,7 @@
|
||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
password: '{{ user.password_hash }}'
|
password: '{{ user.password_hash }}'
|
||||||
update_password: on_create
|
update_password: on_create
|
||||||
when: uidisbusy.rc != 0
|
when: loginisbusy.rc != 0 and uidisbusy.rc != 0
|
||||||
|
|
||||||
- name: "Add Unix account with random uid for '{{ user.name }}'"
|
- name: "Add Unix account with random uid for '{{ user.name }}'"
|
||||||
user:
|
user:
|
||||||
|
@ -26,7 +33,7 @@
|
||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
password: '{{ user.password_hash }}'
|
password: '{{ user.password_hash }}'
|
||||||
update_password: on_create
|
update_password: on_create
|
||||||
when: uidisbusy.rc == 0
|
when: loginisbusy.rc != 0 and uidisbusy.rc == 0
|
||||||
|
|
||||||
- name: "Create {{ admin_users_group }}"
|
- name: "Create {{ admin_users_group }}"
|
||||||
group:
|
group:
|
||||||
|
|
Loading…
Reference in a new issue