Skip to content

Commit c594a1f

Browse files
author
Norman Ziegner
committed
os_hardening: Add test for setting password warning days via variable os_auth_pw_warn_age
Signed-off-by: Norman Ziegner <[email protected]>
1 parent 2f60b44 commit c594a1f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

molecule/os_hardening/converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
os_filesystem_whitelist: []
3030
os_yum_repo_file_whitelist: ['foo.repo']
3131
os_users_without_password_ageing: ['pw_no_ageing']
32+
os_auth_pw_warn_age: 7
3233
os_netrc_enabled: false
3334
os_ignore_users: ["shell_sys_acc"]
3435
os_ignore_home_folder_users: ["user_with_777_home"]

molecule/os_hardening/verify_tasks/pw_ageing.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,19 @@
1414
changed_when: false
1515
register: expiry_date
1616

17-
- name: Check that the expiry date of pw_ageing is 30 days
17+
- name: Check that the expiry date of pw_ageing is 60 days
1818
ansible.builtin.assert:
1919
# this uses the date from the expire_date variable and subtracts the current date.
2020
# it should be bigger that the password_expire_min of the user "pw_no_ageing"
2121
that:
2222
- "{{ ( expiry_date.stdout | trim | to_datetime('%b %d, %Y') - ansible_date_time.date | to_datetime('%Y-%m-%d')).days }} == 60"
23+
24+
- name: Get Password Expiry warning days for pw_ageing
25+
ansible.builtin.shell: chage -l pw_ageing | grep "warning before password expires" | cut -d ":" -f 2
26+
changed_when: false
27+
register: expiry_warndays
28+
29+
- name: Check that number of days of warning before password expires is 7 days
30+
ansible.builtin.assert:
31+
that:
32+
- "expiry_warndays.stdout | trim == '7'"

0 commit comments

Comments
 (0)