Debian Codegraph @

ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/idempotency.yml

raw
1 - name: Test podman pod idempotency
2 block:
3
4 - name: Delete all pods leftovers from tests
5 containers.podman.podman_pod:
6 executable: "{{ test_executable | default('podman') }}"
7 name: "{{ item }}"
8 state: absent
9 loop:
10 - "podidem1"
11 - "podidem2"
12
13 - name: Delete all container leftovers from tests
14 containers.podman.podman_container:
15 executable: "{{ test_executable | default('podman') }}"
16 name: "{{ item }}"
17 state: absent
18 loop:
19 - "container1"
20 - "container2"
21
22 - name: Create pod
23 containers.podman.podman_pod:
24 executable: "{{ test_executable | default('podman') }}"
25 name: podidem1
26 state: created
27 register: podidem1_info
28
29 - name: Check info
30 assert:
31 that:
32 - podidem1_info is changed
33 - >-
34 (podidem1_info.pod['State']['status'] is defined and
35 podidem1_info.pod['State']['status'] == 'Created') or
36 (podidem1_info.pod['State']['status'] is not defined and
37 podidem1_info.pod['State'] == 'Created')
38
39 - name: Create pod again
40 containers.podman.podman_pod:
41 executable: "{{ test_executable | default('podman') }}"
42 name: podidem1
43 state: created
44 register: podidem1_info2
45
46 - name: Check info
47 assert:
48 that:
49 - podidem1_info2 is not changed
50
51 - name: Start pod
52 containers.podman.podman_pod:
53 executable: "{{ test_executable | default('podman') }}"
54 name: podidem1
55 state: started
56 register: podidem1_info3
57
58 - name: Check info
59 assert:
60 that:
61 - podidem1_info3 is changed
62 - >-
63 (podidem1_info3.pod['State']['status'] is defined and
64 podidem1_info3.pod['State']['status'] == 'Running') or
65 (podidem1_info3.pod['State']['status'] is not defined and
66 podidem1_info3.pod['State'] == 'Running')
67
68 - name: Start pod again
69 containers.podman.podman_pod:
70 executable: "{{ test_executable | default('podman') }}"
71 name: podidem1
72 state: started
73 register: podidem1_info4
74
75 - name: Check info
76 assert:
77 that:
78 - podidem1_info4 is not changed
79
80 - name: Stop pod
81 containers.podman.podman_pod:
82 executable: "{{ test_executable | default('podman') }}"
83 name: podidem1
84 state: stopped
85 register: podidem1_info5
86
87 - name: Check info
88 assert:
89 that:
90 - podidem1_info5 is changed
91
92 - name: Stop pod again
93 containers.podman.podman_pod:
94 executable: "{{ test_executable | default('podman') }}"
95 name: podidem1
96 state: stopped
97 register: podidem1_info6
98
99 - name: Check info
100 assert:
101 that:
102 - podidem1_info6 is not changed
103
104 - name: Create stopped pod again
105 containers.podman.podman_pod:
106 executable: "{{ test_executable | default('podman') }}"
107 name: podidem1
108 state: created
109 register: podidem1_info7
110
111 - name: Check info
112 assert:
113 that:
114 - podidem1_info7 is not changed
115
116 - name: Create pod with multiple options and containers
117 containers.podman.podman_pod:
118 executable: "{{ test_executable | default('podman') }}"
119 name: podidem2
120 state: created
121 infra: true
122 network: host
123 share: net
124 userns: auto
125 security_opt:
126 - seccomp=unconfined
127 - apparmor=unconfined
128 hostname: mypod
129 dns:
130 - 1.1.1.1
131 volumes:
132 - /tmp:/tmp/:ro
133 - /var/run/://var/run
134 label:
135 key: cval
136 otherkey: kddkdk
137 somekey: someval
138 add_host:
139 - "google:5.5.5.5"
140 register: podidem2_info
141
142 - name: Check info
143 assert:
144 that:
145 - podidem2_info is changed
146
147 - name: Create same pod
148 containers.podman.podman_pod:
149 executable: "{{ test_executable | default('podman') }}"
150 name: podidem2
151 state: created
152 infra: true
153 network: host
154 share: net
155 userns: auto
156 security_opt:
157 - seccomp=unconfined
158 - apparmor=unconfined
159 hostname: mypod
160 dns:
161 - 1.1.1.1
162 volumes:
163 - /tmp:/tmp/:ro
164 - /var/run/://var/run
165 label:
166 key: cval
167 otherkey: kddkdk
168 somekey: someval
169 add_host:
170 - "google:5.5.5.5"
171 register: podidem2_info2
172
173 - name: Check info
174 assert:
175 that:
176 - podidem2_info2 is not changed
177
178 - name: Change the pod
179 containers.podman.podman_pod:
180 executable: "{{ test_executable | default('podman') }}"
181 name: podidem2
182 state: created
183 infra: true
184 network: host
185 share: net
186 userns: auto
187 security_opt:
188 - seccomp=unconfined
189 - apparmor=unconfined
190 hostname: mypod
191 dns:
192 - 1.1.1.2
193 volumes:
194 - /tmp:/tmp/:ro
195 - /var/run/://var/run
196 label:
197 key: cval
198 otherkey: kddkdk
199 somekey: someval
200 add_host:
201 - "google:5.5.5.5"
202 register: podidem2_info3
203
204 - name: Check info
205 assert:
206 that:
207 - podidem2_info3 is changed
208
209 - name: Start the pod
210 containers.podman.podman_pod:
211 executable: "{{ test_executable | default('podman') }}"
212 name: podidem2
213 state: started
214 infra: true
215 network: host
216 share: net
217 userns: auto
218 security_opt:
219 - seccomp=unconfined
220 - apparmor=unconfined
221 hostname: mypod
222 dns:
223 - 1.1.1.2
224 volumes:
225 - /tmp:/tmp/:ro
226 - /var/run/://var/run
227 label:
228 key: cval
229 otherkey: kddkdk
230 somekey: someval
231 add_host:
232 - "google:5.5.5.5"
233
234 - name: Configure and start the pod again
235 containers.podman.podman_pod:
236 executable: "{{ test_executable | default('podman') }}"
237 name: podidem2
238 state: started
239 infra: true
240 network: host
241 share: net
242 userns: auto
243 security_opt:
244 - seccomp=unconfined
245 - apparmor=unconfined
246 hostname: mypod
247 dns:
248 - 1.1.1.2
249 volumes:
250 - /tmp:/tmp/:ro
251 - /var/run/://var/run
252 label:
253 key: cval
254 otherkey: kddkdk
255 somekey: someval
256 add_host:
257 - "google:5.5.5.5"
258 register: podidem2_info4
259
260 - name: Check info
261 assert:
262 that:
263 - podidem2_info4 is not changed
264
265 - name: Remove pod
266 containers.podman.podman_pod:
267 executable: "{{ test_executable | default('podman') }}"
268 name: podidem2
269 state: absent
270
271 - name: Create a pod with parameters - created
272 containers.podman.podman_pod:
273 executable: "{{ test_executable | default('podman') }}"
274 name: podidem2
275 state: created
276 infra: true
277 network: host
278 share: net
279 userns: auto
280 security_opt:
281 - seccomp=unconfined
282 - apparmor=unconfined
283 hostname: mypod
284 dns:
285 - 1.1.1.2
286 volumes:
287 - /tmp:/tmp/:ro
288 label:
289 key: cval
290 otherkey: kddkdk
291 somekey: someval
292 add_host:
293 - "google:5.5.5.5"
294 register: pod1_set
295
296 - name: Create containers
297 containers.podman.podman_container:
298 executable: "{{ test_executable | default('podman') }}"
299 name: "{{ item }}"
300 state: created
301 pod: podidem2
302 image: alpine
303 command: sleep 1h
304 loop:
305 - "container1"
306 - "container2"
307
308 - name: Start pod
309 containers.podman.podman_pod:
310 executable: "{{ test_executable | default('podman') }}"
311 name: podidem2
312 state: started
313 infra: true
314 network: host
315 share: net
316 userns: auto
317 security_opt:
318 - seccomp=unconfined
319 - apparmor=unconfined
320 hostname: mypod
321 dns:
322 - 1.1.1.2
323 volumes:
324 - /tmp:/tmp/:ro
325 label:
326 key: cval
327 otherkey: kddkdk
328 somekey: someval
329 add_host:
330 - "google:5.5.5.5"
331 register: pod2_set
332
333 - name: Check info for pod creation
334 assert:
335 that:
336 - pod1_set is changed
337 - pod2_set is changed
338 - pod1_set.pod['State'] == 'Created'
339 - pod1_set.pod['Containers'][0]['State'] == 'created'
340 - pod2_set.pod['State'] == 'Running'
341 - pod2_set.pod['Containers'][0]['State'] == 'running'
342 - pod2_set.pod['Containers'][1]['State'] == 'running'
343 - pod2_set.pod['Containers'][2]['State'] == 'running'
344
345 always:
346
347 - name: Delete all pods leftovers from tests
348 containers.podman.podman_pod:
349 executable: "{{ test_executable | default('podman') }}"
350 name: "{{ item }}"
351 state: absent
352 loop:
353 - "podidem1"
354 - "podidem1"
355
356 - name: Delete all container leftovers from tests
357 containers.podman.podman_container:
358 executable: "{{ test_executable | default('podman') }}"
359 name: "{{ item }}"
360 state: absent
361 loop:
362 - "container1"
363 - "container2"