Skip to content

Commit

Permalink
split tasks for locking and setting shell
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Schurz <Martin.Schurz@t-systems.com>
  • Loading branch information
schurzi committed Jan 26, 2023
1 parent 083fc7a commit 7f91dda
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions roles/os_hardening/tasks/user_accounts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,21 @@
- root_users|length > 1
- item != "root"

- name: Remove shell+password for linux system accounts
ansible.builtin.user:
- name: remove shell for linux system accounts
user:
name: '{{ item }}'
shell: '{{ os_nologin_shell_path }}'
createhome: false
loop: "{{ system_users }}"

- name: lock passwords from linux system accounts
user:
name: '{{ item }}'
password: '*'
createhome: false
loop: "{{ system_users }}"
when:
- getent_shadow[item][0] is not match("\!") # password hashes containing illegal characters like "!" are unusable already (locked)

- name: Get all home directories in /home, but skip ignored users
ansible.builtin.find:
Expand Down

0 comments on commit 7f91dda

Please sign in to comment.