forked from ansible-lockdown/RHEL9-CIS
lint and best practise
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
This commit is contained in:
parent
69e01b84f3
commit
fcf9eb674f
6 changed files with 33 additions and 30 deletions
|
|
@ -81,14 +81,14 @@
|
|||
vars:
|
||||
sudo_password_rule: rhel9cis_rule_5_2_4 # pragma: allowlist secret
|
||||
block:
|
||||
- name: "Check password set for {{ ansible_env.SUDO_USER }} | password state"
|
||||
- name: "Check password set for {{ ansible_env.SUDO_USER }} | password state" # noqa name[template]
|
||||
ansible.builtin.shell: "(grep {{ ansible_env.SUDO_USER }} /etc/shadow || echo 'not found:not found') | awk -F: '{print $2}'"
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
check_mode: false
|
||||
register: prelim_ansible_user_password_set
|
||||
|
||||
- name: "Check for local account {{ ansible_env.SUDO_USER }} | Check for local account"
|
||||
- name: "Check for local account {{ ansible_env.SUDO_USER }} | Check for local account" # noqa name[template]
|
||||
when: prelim_ansible_user_password_set.stdout == "not found"
|
||||
ansible.builtin.debug:
|
||||
msg: "No local account found for {{ ansible_env.SUDO_USER }} user. Skipping local account checks."
|
||||
|
|
@ -97,7 +97,7 @@
|
|||
when:
|
||||
- prelim_ansible_user_password_set.stdout != "not found"
|
||||
block:
|
||||
- name: "Check password set for {{ ansible_env.SUDO_USER }} | Assert local password set"
|
||||
- name: "Check password set for {{ ansible_env.SUDO_USER }} | Assert local password set" # noqa name[template]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- prelim_ansible_user_password_set.stdout | length != 0
|
||||
|
|
@ -105,7 +105,7 @@
|
|||
fail_msg: "You have {{ sudo_password_rule }} enabled but the user = {{ ansible_env.SUDO_USER }} has no password set - It can break access"
|
||||
success_msg: "You have a password set for the {{ ansible_env.SUDO_USER }} user"
|
||||
|
||||
- name: "Check account is not locked for {{ ansible_env.SUDO_USER }} | Assert local account not locked"
|
||||
- name: "Check account is not locked for {{ ansible_env.SUDO_USER }} | Assert local account not locked" # noqa name[template]
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- not prelim_ansible_user_password_set.stdout.startswith("!")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue