Debian Codegraph @

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

raw
1 # Test setting no expiration when creating a new account
2 # https://github.com/ansible/ansible/issues/44155
3 - name: Remove ansibulluser
4 user:
5 name: ansibulluser
6 state: absent
7
8 - name: Create user account without expiration
9 user:
10 name: ansibulluser
11 state: present
12 expires: -1
13 register: user_test_create_no_expires_1
14
15 - name: Create user account without expiration again
16 user:
17 name: ansibulluser
18 state: present
19 expires: -1
20 register: user_test_create_no_expires_2
21
22 - name: Ensure changes were made appropriately
23 assert:
24 msg: Setting 'expires='-1 resulted in incorrect changes
25 that:
26 - user_test_create_no_expires_1 is changed
27 - user_test_create_no_expires_2 is not changed
28
29 - name: Verify un expiration date for Linux
30 block:
31 - name: LINUX | Get expiration date for ansibulluser
32 getent:
33 database: shadow
34 key: ansibulluser
35
36 - name: LINUX | Ensure proper expiration date was set
37 assert:
38 msg: "expiry is supposed to be empty or -1, not {{ getent_shadow['ansibulluser'][6] }}"
39 that:
40 - not getent_shadow['ansibulluser'][6] or getent_shadow['ansibulluser'][6] | int < 0
41 when: ansible_facts.os_family in ['RedHat', 'Debian']
42
43 - name: Verify un expiration date for BSD
44 block:
45 - name: BSD | Get expiration date for ansibulluser
46 shell: 'grep ansibulluser /etc/master.passwd | cut -d: -f 7'
47 changed_when: no
48 register: bsd_account_expiration
49
50 - name: BSD | Ensure proper expiration date was set
51 assert:
52 msg: "expiry is supposed to be '0', not {{ bsd_account_expiration.stdout }}"
53 that:
54 - bsd_account_expiration.stdout == '0'
55 when: ansible_facts.os_family == 'FreeBSD'