Skip to content

Commit

Permalink
os_hardening: Add test for setting password warning days via variable…
Browse files Browse the repository at this point in the history
… os_auth_pw_warn_age

Signed-off-by: Norman Ziegner <[email protected]>
  • Loading branch information
Norman Ziegner committed Feb 3, 2023
1 parent 2f60b44 commit c594a1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions molecule/os_hardening/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
os_filesystem_whitelist: []
os_yum_repo_file_whitelist: ['foo.repo']
os_users_without_password_ageing: ['pw_no_ageing']
os_auth_pw_warn_age: 7
os_netrc_enabled: false
os_ignore_users: ["shell_sys_acc"]
os_ignore_home_folder_users: ["user_with_777_home"]
Expand Down
12 changes: 11 additions & 1 deletion molecule/os_hardening/verify_tasks/pw_ageing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@
changed_when: false
register: expiry_date

- name: Check that the expiry date of pw_ageing is 30 days
- name: Check that the expiry date of pw_ageing is 60 days
ansible.builtin.assert:
# this uses the date from the expire_date variable and subtracts the current date.
# it should be bigger that the password_expire_min of the user "pw_no_ageing"
that:
- "{{ ( expiry_date.stdout | trim | to_datetime('%b %d, %Y') - ansible_date_time.date | to_datetime('%Y-%m-%d')).days }} == 60"

- name: Get Password Expiry warning days for pw_ageing
ansible.builtin.shell: chage -l pw_ageing | grep "warning before password expires" | cut -d ":" -f 2
changed_when: false
register: expiry_warndays

- name: Check that number of days of warning before password expires is 7 days
ansible.builtin.assert:
that:
- "expiry_warndays.stdout | trim == '7'"

0 comments on commit c594a1f

Please sign in to comment.