Debian Codegraph @

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

raw
1 # Date is March 3, 2050
2 - name: Set user expiration
3 user:
4 name: ansibulluser
5 state: present
6 expires: 2529881062
7 register: user_test_expires1
8
9 - name: Set user expiration again to ensure no change is made
10 user:
11 name: ansibulluser
12 state: present
13 expires: 2529881062
14 register: user_test_expires2
15
16 - name: Ensure that account with expiration was created and did not change on subsequent run
17 assert:
18 that:
19 - user_test_expires1 is changed
20 - user_test_expires2 is not changed
21
22 - name: Verify expiration date for Linux
23 block:
24 - name: LINUX | Get expiration date for ansibulluser
25 getent:
26 database: shadow
27 key: ansibulluser
28
29 - name: LINUX | Ensure proper expiration date was set
30 assert:
31 that:
32 - getent_shadow['ansibulluser'][6] == '29281'
33 when: ansible_facts.os_family in ['RedHat', 'Debian']
34
35
36 - name: Verify expiration date for BSD
37 block:
38 - name: BSD | Get expiration date for ansibulluser
39 shell: 'grep ansibulluser /etc/master.passwd | cut -d: -f 7'
40 changed_when: no
41 register: bsd_account_expiration
42
43 - name: BSD | Ensure proper expiration date was set
44 assert:
45 that:
46 - bsd_account_expiration.stdout == '2529881062'
47 when: ansible_facts.os_family == 'FreeBSD'
48
49 - name: Unexpire user
50 user:
51 name: ansibulluser
52 state: present
53 expires: -1
54 register: user_test_expires3
55
56 - name: Verify un expiration date for Linux
57 block:
58 - name: LINUX | Get expiration date for ansibulluser
59 getent:
60 database: shadow
61 key: ansibulluser
62
63 - name: LINUX | Ensure proper expiration date was set
64 assert:
65 msg: "expiry is supposed to be empty or -1, not {{ getent_shadow['ansibulluser'][6] }}"
66 that:
67 - not getent_shadow['ansibulluser'][6] or getent_shadow['ansibulluser'][6] | int < 0
68 when: ansible_facts.os_family in ['RedHat', 'Debian']
69
70 - name: Verify un expiration date for Linux/BSD
71 block:
72 - name: Unexpire user again to check for change
73 user:
74 name: ansibulluser
75 state: present
76 expires: -1
77 register: user_test_expires4
78
79 - name: Ensure first expiration reported a change and second did not
80 assert:
81 msg: The second run of the expiration removal task reported a change when it should not
82 that:
83 - user_test_expires3 is changed
84 - user_test_expires4 is not changed
85 when: ansible_facts.os_family in ['RedHat', 'Debian', 'FreeBSD']
86
87 - name: Verify un expiration date for BSD
88 block:
89 - name: BSD | Get expiration date for ansibulluser
90 shell: 'grep ansibulluser /etc/master.passwd | cut -d: -f 7'
91 changed_when: no
92 register: bsd_account_expiration
93
94 - name: BSD | Ensure proper expiration date was set
95 assert:
96 msg: "expiry is supposed to be '0', not {{ bsd_account_expiration.stdout }}"
97 that:
98 - bsd_account_expiration.stdout == '0'
99 when: ansible_facts.os_family == 'FreeBSD'