Debian Codegraph @

test/integration/targets/user/tasks/test_expires_no_shadow.yml

raw
1 # https://github.com/ansible/ansible/issues/71916
2 - name: Test setting expiration for a user account that does not have an /etc/shadow entry
3 when: ansible_facts.os_family in ['RedHat', 'Debian']
4 block:
5 - name: Remove ansibulluser
6 user:
7 name: ansibulluser
8 state: absent
9 remove: yes
10
11 - name: Create user account entry in /etc/passwd
12 lineinfile:
13 path: /etc/passwd
14 line: "ansibulluser::575:575::/home/dummy:/bin/bash"
15 regexp: "^ansibulluser.*"
16 state: present
17
18 - name: Create user with negative expiration
19 user:
20 name: ansibulluser
21 uid: 575
22 expires: -1
23 register: user_test_expires_no_shadow_1
24
25 - name: Create user with negative expiration again
26 user:
27 name: ansibulluser
28 uid: 575
29 expires: -1
30 register: user_test_expires_no_shadow_2
31
32 - name: Ensure changes were made appropriately
33 assert:
34 that:
35 - user_test_expires_no_shadow_1 is changed
36 - user_test_expires_no_shadow_2 is not changed
37
38 - name: Get expiration date for ansibulluser
39 getent:
40 database: shadow
41 key: ansibulluser
42
43 - name: LINUX | Ensure proper expiration date was set
44 assert:
45 msg: "expiry is supposed to be empty or -1, not {{ getent_shadow['ansibulluser'][6] }}"
46 that:
47 - not getent_shadow['ansibulluser'][6] or getent_shadow['ansibulluser'][6] | int < 0