Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/sefcontext/tasks/sefcontext.yml

raw
1 ---
2 # Copyright (c) 2016, Dag Wieers <[email protected]>
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: install requirements for RHEL
7 package:
8 name: policycoreutils-python
9 when:
10 - ansible_facts.distribution == 'RedHat'
11 - ansible_facts.distribution_major_version|int < 8
12
13 - name: install requirements for rhel8 beta
14 package:
15 name: python3-policycoreutils
16 when:
17 - ansible_facts.distribution == 'RedHat'
18 - ansible_facts.distribution_major_version|int >= 8
19
20 - name: Ensure we start with a clean state
21 sefcontext:
22 path: '/tmp/foo/bar(/.*)?'
23 setype: httpd_sys_content_t
24 state: absent
25
26 - name: Ensure we start with a clean state
27 sefcontext:
28 path: /tmp/foo
29 state: absent
30
31 - name: Set SELinux file context of foo/bar
32 sefcontext:
33 path: '/tmp/foo/bar(/.*)?'
34 setype: httpd_sys_content_t
35 state: present
36 reload: false
37 register: first
38
39 - assert:
40 that:
41 - first is changed
42 - first.setype == 'httpd_sys_content_t'
43
44 - name: Set SELinux file context of foo/bar (again)
45 sefcontext:
46 path: '/tmp/foo/bar(/.*)?'
47 setype: httpd_sys_content_t
48 state: present
49 reload: false
50 register: second
51
52 - assert:
53 that:
54 - second is not changed
55 - second.setype == 'httpd_sys_content_t'
56
57 - name: Change SELinux file context of foo/bar
58 sefcontext:
59 path: '/tmp/foo/bar(/.*)?'
60 setype: unlabeled_t
61 state: present
62 reload: false
63 register: third
64
65 - assert:
66 that:
67 - third is changed
68 - third.setype == 'unlabeled_t'
69
70 - name: Change SELinux file context of foo/bar (again)
71 sefcontext:
72 path: '/tmp/foo/bar(/.*)?'
73 setype: unlabeled_t
74 state: present
75 reload: false
76 register: fourth
77
78 - assert:
79 that:
80 - fourth is not changed
81 - fourth.setype == 'unlabeled_t'
82
83 - name: Delete SELinux file context of foo/bar
84 sefcontext:
85 path: '/tmp/foo/bar(/.*)?'
86 setype: httpd_sys_content_t
87 state: absent
88 reload: false
89 register: fifth
90
91 - assert:
92 that:
93 - fifth is changed
94 - fifth.setype == 'httpd_sys_content_t'
95
96 - name: Delete SELinux file context of foo/bar (again)
97 sefcontext:
98 path: '/tmp/foo/bar(/.*)?'
99 setype: unlabeled_t
100 state: absent
101 reload: false
102 register: sixth
103
104 - assert:
105 that:
106 - sixth is not changed
107 - sixth.setype == 'unlabeled_t'
108
109 - name: Set SELinux file context path substitution of foo
110 sefcontext:
111 path: /tmp/foo
112 substitute: /home
113 state: present
114 reload: false
115 register: subst_first
116
117 - assert:
118 that:
119 - subst_first is changed
120 - subst_first.substitute == '/home'
121
122 - name: Set SELinux file context path substitution of foo (again)
123 sefcontext:
124 path: /tmp/foo
125 substitute: /home
126 state: present
127 reload: false
128 register: subst_second
129
130 - assert:
131 that:
132 - subst_second is not changed
133 - subst_second.substitute == '/home'
134
135 - name: Change SELinux file context path substitution of foo
136 sefcontext:
137 path: /tmp/foo
138 substitute: /boot
139 state: present
140 reload: false
141 register: subst_third
142
143 - assert:
144 that:
145 - subst_third is changed
146 - subst_third.substitute == '/boot'
147
148 - name: Change SELinux file context path substitution of foo (again)
149 sefcontext:
150 path: /tmp/foo
151 substitute: /boot
152 state: present
153 reload: false
154 register: subst_fourth
155
156 - assert:
157 that:
158 - subst_fourth is not changed
159 - subst_fourth.substitute == '/boot'
160
161 - name: Try to delete non-existing SELinux file context path substitution of foo
162 sefcontext:
163 path: /tmp/foo
164 substitute: /dev
165 state: absent
166 reload: false
167 register: subst_fifth
168
169 - assert:
170 that:
171 - subst_fifth is not changed
172 - subst_fifth.substitute == '/dev'
173
174 - name: Delete SELinux file context path substitution of foo
175 sefcontext:
176 path: /tmp/foo
177 substitute: /boot
178 state: absent
179 reload: false
180 register: subst_sixth
181
182 - assert:
183 that:
184 - subst_sixth is changed
185 - subst_sixth.substitute == '/boot'
186
187 - name: Delete SELinux file context path substitution of foo (again)
188 sefcontext:
189 path: /tmp/foo
190 substitute: /boot
191 state: absent
192 reload: false
193 register: subst_seventh
194
195 - assert:
196 that:
197 - subst_seventh is not changed
198 - subst_seventh.substitute == '/boot'
199
200 - name: Set SELinux file context path substitution of foo
201 sefcontext:
202 path: /tmp/foo
203 substitute: /home
204 state: present
205 reload: false
206 register: subst_eighth
207
208 - assert:
209 that:
210 - subst_eighth is changed
211 - subst_eighth.substitute == '/home'
212
213 - name: Delete SELinux file context path substitution of foo
214 sefcontext:
215 path: /tmp/foo
216 state: absent
217 reload: false
218 register: subst_ninth
219
220 - assert:
221 that:
222 - subst_ninth is changed
223
224 - name: Delete SELinux file context path substitution of foo (again)
225 sefcontext:
226 path: /tmp/foo
227 state: absent
228 reload: false
229 register: subst_tenth
230
231 - assert:
232 that:
233 - subst_tenth is not changed