apply password age settings to exisiting regular users (#582)
* 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]>
This commit is contained in:
8 files changed
+82
-3
No files matched your search
@@ -28,6 +28,7 @@
|
||||
os_security_suid_sgid_whitelist: ['/usr/bin/rlogin']
|
||||
os_filesystem_whitelist: []
|
||||
os_yum_repo_file_whitelist: ['foo.repo']
|
||||
os_users_without_password_ageing: ['pw_no_ageing']
|
||||
os_netrc_enabled: false
|
||||
sysctl_config:
|
||||
net.ipv4.ip_forward: 0
|
||||
|
||||
@@ -59,6 +59,8 @@
|
||||
include_tasks: prepare_tasks/yum.yml
|
||||
when: ansible_facts.os_family == 'RedHat'
|
||||
|
||||
- name: include YUM prepare tasks
|
||||
- name: include netrc prepare tasks
|
||||
include_tasks: prepare_tasks/netrc.yml
|
||||
|
||||
- name: include password ageing prepare tasks
|
||||
include_tasks: prepare_tasks/pw_ageing.yml
|
||||
@@ -0,0 +1,9 @@
|
||||
- name: Create user those password ageing should not be changed
|
||||
user:
|
||||
name: "pw_no_ageing"
|
||||
password: "$6$mysecretsalt$qJbapG68nyRab3gxvKWPUcs2g3t0oMHSHMnSKecYNpSi3CuZm.GbBqXO8BE6EI6P1JUefhA0qvD7b5LSh./PU1"
|
||||
|
||||
- name: Create user those password ageing should be changed
|
||||
user:
|
||||
name: "pw_ageing"
|
||||
password: "$6$mysecretsalt$qJbapG68nyRab3gxvKWPUcs2g3t0oMHSHMnSKecYNpSi3CuZm.GbBqXO8BE6EI6P1JUefhA0qvD7b5LSh./PU1"
|
||||
@@ -37,6 +37,9 @@
|
||||
name: procps
|
||||
when: ansible_facts.os_family == 'Debian'
|
||||
|
||||
- name: include password ageing tests
|
||||
include_tasks: verify_tasks/pw_ageing.yml
|
||||
|
||||
- name: include netrc tests
|
||||
include_tasks: verify_tasks/netrc.yml
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
- 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"
|
||||
Reference in new issue
Block a user