Debian Codegraph @

test/integration/targets/lineinfile/tasks/acls.yml

raw
1 - block:
2 - name: Install the acl package on Ubuntu
3 apt:
4 name: acl
5 when: ansible_distribution in ('Ubuntu')
6 register: setup_acl
7
8 - name: Install the acl package on RedHat
9 dnf:
10 name: acl
11 when: ansible_distribution in ('RedHat')
12 register: setup_acl
13
14 - name: Create file
15 copy:
16 content: "TEST"
17 mode: 0644
18 dest: "~/test.txt"
19
20 - shell: setfacl -m nobody:rwx ~/test.txt
21
22 - shell: getfacl ~/test.txt
23 register: acls
24
25 - name: Check that permissions match with the copy mode and setfacl command
26 assert:
27 that:
28 - "'user::rw-' in acls.stdout_lines"
29 - "'user:nobody:rwx' in acls.stdout_lines"
30 - "'group::r--' in acls.stdout_lines"
31 - "'other::r--' in acls.stdout_lines"
32
33 - name: test atomic_move via lineinfile doesn't delete extended acls
34 lineinfile:
35 path: "~/test.txt"
36 regexp: "TEST"
37 line: "UPDATE"
38
39 - shell: getfacl ~/test.txt
40 register: acls
41
42 - name: Validate the acls are unmodified
43 assert:
44 that:
45 - "'user::rw-' in acls.stdout_lines"
46 - "'user:nobody:rwx' in acls.stdout_lines"
47 - "'group::r--' in acls.stdout_lines"
48 - "'other::r--' in acls.stdout_lines"
49
50 always:
51 - name: Remove the acl package on Ubuntu
52 apt:
53 name: acl
54 state: absent
55 when: setup_acl is changed and ansible_distribution in ('Ubuntu')
56
57 - name: Remove the acl package on RedHat
58 dnf:
59 name: acl
60 state: absent
61 when: setup_acl is changed and ansible_distribution in ('RedHat')
62
63 - name: Clean up
64 file:
65 path: "~/test.txt"
66 state: absent