* apply password age settings to regular users * add tests for password ageing Signed-off-by: Sebastian Gumprich <[email protected]> * add debugging vars Signed-off-by: Sebastian Gumprich <[email protected]> * add tests for password ageing Signed-off-by: Sebastian Gumprich <[email protected]> * add tests for password ageing Signed-off-by: Sebastian Gumprich <[email protected]> * Apply suggestions from code review Co-authored-by: schurzi <[email protected]> * add additional condtion for regular users Signed-off-by: Sebastian Gumprich <[email protected]> Signed-off-by: Sebastian Gumprich <[email protected]> Co-authored-by: DonEstefan <[email protected]> Co-authored-by: Sebastian Gumprich <[email protected]> Co-authored-by: Sebastian Gumprich <[email protected]> Co-authored-by: schurzi <[email protected]>
23 lines
922 B
YAML
23 lines
922 B
YAML
---
|
|
- name: Get Password Expiry date for use pw_no_ageing
|
|
ansible.builtin.shell: chage -l pw_no_ageing | grep "Password expires" | cut -d ":" -f 2
|
|
changed_when: false
|
|
register: expiry_date
|
|
|
|
- name: Check that the expiry date of pw_no_ageing is "never"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "expiry_date.stdout | trim == 'never'"
|
|
|
|
- name: Get Password Expiry date for pw_ageing
|
|
ansible.builtin.shell: chage -l pw_ageing | grep "Password expires" | cut -d ":" -f 2
|
|
changed_when: false
|
|
register: expiry_date
|
|
|
|
- name: Check that the expiry date of pw_ageing is 30 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"
|