os_hardening: Add test for setting password warning days via variable os_auth_pw_warn_age

Signed-off-by: Norman Ziegner <norman.ziegner@ufz.de>
This commit is contained in:
Norman Ziegner 2023-02-01 16:19:18 +01:00
parent 2f60b44cca
commit c594a1fe6a
No known key found for this signature in database
GPG key ID: 4157B9737AFF4EF7
2 changed files with 12 additions and 1 deletions

View file

@ -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"]

View file

@ -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'"