Skip to content
Snippets Groups Projects
Commit 9f71b2ee authored by nimrod's avatar nimrod
Browse files

- Better handling of not removing the nobody user.

parent 72a64e80
No related branches found
No related tags found
No related merge requests found
......@@ -10,9 +10,13 @@
command: whoami
register: users_whoami
- name: Get the nobody uid
command: id -u nobody
register: users_nobody_uid
- name: Prune users
with_items: '{{ getent_passwd|difference(users_unique_names) }}'
when: getent_passwd[item][2]|int > 999 and getent_passwd[item][2]|int != 65534 and item != users_whoami.stdout.strip()
with_items: '{{ getent_passwd|difference(users_unique_names)|difference(["nobody", users_whoami.stdout.strip()]) }}'
when: getent_passwd[item][2]|int > 999 and getent_passwd[item][2] != users_nobody_uid.stdout.strip() # Actual, non-system users.
user:
name: '{{ item }}'
state: absent
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment