| 1 |
- name: Test multiple podman_containers |
| 2 |
block: |
| 3 |
- name: Delete all containers leftovers from tests |
| 4 |
containers.podman.podman_containers: |
| 5 |
containers: |
| 6 |
- name: "alpine:3.7" |
| 7 |
state: absent |
| 8 |
executable: "{{ test_executable | default('podman') }}" |
| 9 |
- name: "container" |
| 10 |
state: absent |
| 11 |
executable: "{{ test_executable | default('podman') }}" |
| 12 |
- name: "container1" |
| 13 |
state: absent |
| 14 |
executable: "{{ test_executable | default('podman') }}" |
| 15 |
- name: "container2" |
| 16 |
state: absent |
| 17 |
executable: "{{ test_executable | default('podman') }}" |
| 18 |
- name: "container3" |
| 19 |
state: absent |
| 20 |
executable: "{{ test_executable | default('podman') }}" |
| 21 |
- name: "container4" |
| 22 |
state: absent |
| 23 |
executable: "{{ test_executable | default('podman') }}" |
| 24 |
- name: "testidem" |
| 25 |
state: absent |
| 26 |
executable: "{{ test_executable | default('podman') }}" |
| 27 |
- name: "testidem1" |
| 28 |
state: absent |
| 29 |
executable: "{{ test_executable | default('podman') }}" |
| 30 |
- name: "testidem2" |
| 31 |
state: absent |
| 32 |
executable: "{{ test_executable | default('podman') }}" |
| 33 |
- name: "testidem3" |
| 34 |
state: absent |
| 35 |
executable: "{{ test_executable | default('podman') }}" |
| 36 |
- name: "testidem-pod" |
| 37 |
state: absent |
| 38 |
executable: "{{ test_executable | default('podman') }}" |
| 39 |
- name: "testidem-pod2" |
| 40 |
state: absent |
| 41 |
executable: "{{ test_executable | default('podman') }}" |
| 42 |
|
| 43 |
- name: Test no image with default action |
| 44 |
containers.podman.podman_containers: |
| 45 |
containers: |
| 46 |
- name: "container" |
| 47 |
executable: "{{ test_executable | default('podman') }}" |
| 48 |
- name: "container2" |
| 49 |
executable: "{{ test_executable | default('podman') }}" |
| 50 |
- name: "container3" |
| 51 |
executable: "{{ test_executable | default('podman') }}" |
| 52 |
image: alpine |
| 53 |
ignore_errors: true |
| 54 |
register: no_image |
| 55 |
|
| 56 |
- name: Test no image with state 'started' |
| 57 |
containers.podman.podman_containers: |
| 58 |
containers: |
| 59 |
- name: "container" |
| 60 |
state: started |
| 61 |
executable: "{{ test_executable | default('podman') }}" |
| 62 |
- name: "container2" |
| 63 |
state: started |
| 64 |
executable: "{{ test_executable | default('podman') }}" |
| 65 |
ignore_errors: true |
| 66 |
register: no_image1 |
| 67 |
|
| 68 |
- name: Test no image with state 'present' |
| 69 |
containers.podman.podman_containers: |
| 70 |
containers: |
| 71 |
- name: "container" |
| 72 |
state: present |
| 73 |
executable: "{{ test_executable | default('podman') }}" |
| 74 |
- name: "container2" |
| 75 |
state: present |
| 76 |
executable: "{{ test_executable | default('podman') }}" |
| 77 |
- name: "container3" |
| 78 |
state: present |
| 79 |
image: alpine |
| 80 |
executable: "{{ test_executable | default('podman') }}" |
| 81 |
ignore_errors: true |
| 82 |
register: no_image2 |
| 83 |
|
| 84 |
- name: Check no image |
| 85 |
assert: |
| 86 |
that: |
| 87 |
- no_image is failed |
| 88 |
- no_image1 is failed |
| 89 |
- no_image2 is failed |
| 90 |
- no_image.msg is search("State 'started' required image to be configured!") |
| 91 |
- no_image1.msg is search ("State 'started' required image to be configured!") |
| 92 |
- no_image2.msg is search("State 'present' required image to be configured!") |
| 93 |
fail_msg: No-image test failed! |
| 94 |
success_msg: No-image test passed! |
| 95 |
|
| 96 |
- name: Ensure image doesn't exist |
| 97 |
containers.podman.podman_image: |
| 98 |
name: alpine:3.7 |
| 99 |
state: absent |
| 100 |
executable: "{{ test_executable | default('podman') }}" |
| 101 |
|
| 102 |
- name: Check pulling image |
| 103 |
containers.podman.podman_containers: |
| 104 |
containers: |
| 105 |
- name: container |
| 106 |
image: alpine:3.7 |
| 107 |
state: started |
| 108 |
command: sleep 1d |
| 109 |
executable: "{{ test_executable | default('podman') }}" |
| 110 |
- name: container1 |
| 111 |
image: alpine:3.7 |
| 112 |
state: started |
| 113 |
command: sleep 1d |
| 114 |
executable: "{{ test_executable | default('podman') }}" |
| 115 |
register: image |
| 116 |
|
| 117 |
- name: Check using already pulled image |
| 118 |
containers.podman.podman_containers: |
| 119 |
containers: |
| 120 |
- name: container1 |
| 121 |
image: alpine:3.7 |
| 122 |
state: started |
| 123 |
command: sleep 1d |
| 124 |
executable: "{{ test_executable | default('podman') }}" |
| 125 |
- name: container3 |
| 126 |
image: alpine:3.7 |
| 127 |
state: started |
| 128 |
command: sleep 1d |
| 129 |
executable: "{{ test_executable | default('podman') }}" |
| 130 |
register: image2 |
| 131 |
|
| 132 |
- name: Check output is correct |
| 133 |
assert: |
| 134 |
that: |
| 135 |
- image is changed |
| 136 |
- image.containers[0] is defined |
| 137 |
- image.containers[0]['State']['Running'] |
| 138 |
- image.containers[1] is defined |
| 139 |
- image.containers[1]['State']['Running'] |
| 140 |
- "'pulled image alpine:3.7' in image.actions" |
| 141 |
- "'started container' in image.actions" |
| 142 |
- "'started container1' in image.actions" |
| 143 |
- image2 is changed |
| 144 |
- image2.containers is defined |
| 145 |
- image2.containers[0]['State']['Running'] |
| 146 |
- image2.containers[1]['State']['Running'] |
| 147 |
- "'pulled image alpine:3.7' not in image2.actions" |
| 148 |
- "'started container3' in image2.actions" |
| 149 |
fail_msg: Pulling image test failed! |
| 150 |
success_msg: Pulling image test passed! |
| 151 |
|
| 152 |
- name: Check failed image pull |
| 153 |
containers.podman.podman_containers: |
| 154 |
containers: |
| 155 |
- name: container1 |
| 156 |
image: alpine:3.7 |
| 157 |
state: started |
| 158 |
command: sleep 1d |
| 159 |
executable: "{{ test_executable | default('podman') }}" |
| 160 |
- name: container |
| 161 |
image: ineverneverneverexist |
| 162 |
state: started |
| 163 |
command: sleep 1d |
| 164 |
executable: "{{ test_executable | default('podman') }}" |
| 165 |
register: imagefail |
| 166 |
ignore_errors: true |
| 167 |
|
| 168 |
- name: Check output is correct |
| 169 |
assert: |
| 170 |
that: |
| 171 |
- imagefail is failed |
| 172 |
- imagefail.msg == "Can't pull image ineverneverneverexist" |
| 173 |
|
| 174 |
- name: Force containers recreate |
| 175 |
containers.podman.podman_containers: |
| 176 |
containers: |
| 177 |
- name: container1 |
| 178 |
image: alpine:3.7 |
| 179 |
state: present |
| 180 |
command: sleep 1d |
| 181 |
executable: "{{ test_executable | default('podman') }}" |
| 182 |
- name: container |
| 183 |
image: alpine |
| 184 |
state: present |
| 185 |
command: sleep 1d |
| 186 |
recreate: true |
| 187 |
executable: "{{ test_executable | default('podman') }}" |
| 188 |
register: recreated |
| 189 |
|
| 190 |
- name: Check output is correct |
| 191 |
assert: |
| 192 |
that: |
| 193 |
- recreated is changed |
| 194 |
- recreated.containers is defined |
| 195 |
- recreated.containers[1]['State']['Running'] |
| 196 |
- "'recreated container' in recreated.actions" |
| 197 |
fail_msg: Force recreate test failed! |
| 198 |
success_msg: Force recreate test passed! |
| 199 |
|
| 200 |
- name: Stop containers |
| 201 |
containers.podman.podman_containers: |
| 202 |
containers: |
| 203 |
- name: container |
| 204 |
state: stopped |
| 205 |
executable: "{{ test_executable | default('podman') }}" |
| 206 |
- name: container1 |
| 207 |
state: stopped |
| 208 |
executable: "{{ test_executable | default('podman') }}" |
| 209 |
register: stopped |
| 210 |
|
| 211 |
- name: Stop the same containers again (idempotency) |
| 212 |
containers.podman.podman_containers: |
| 213 |
containers: |
| 214 |
- name: container |
| 215 |
state: stopped |
| 216 |
executable: "{{ test_executable | default('podman') }}" |
| 217 |
- name: container1 |
| 218 |
state: stopped |
| 219 |
executable: "{{ test_executable | default('podman') }}" |
| 220 |
register: stopped_again |
| 221 |
|
| 222 |
- name: Check output is correct |
| 223 |
assert: |
| 224 |
that: |
| 225 |
- stopped is changed |
| 226 |
- stopped.containers is defined |
| 227 |
- not stopped.containers[0]['State']['Running'] |
| 228 |
- not stopped.containers[1]['State']['Running'] |
| 229 |
- "'stopped container' in stopped.actions" |
| 230 |
- stopped_again is not changed |
| 231 |
- stopped_again.containers is defined |
| 232 |
- not stopped_again.containers[0]['State']['Running'] |
| 233 |
- not stopped_again.containers[1]['State']['Running'] |
| 234 |
- stopped_again.actions == [] |
| 235 |
fail_msg: Stopping container test failed! |
| 236 |
success_msg: Stopping container test passed! |
| 237 |
|
| 238 |
- name: Delete stopped containers |
| 239 |
containers.podman.podman_containers: |
| 240 |
containers: |
| 241 |
- name: container |
| 242 |
state: absent |
| 243 |
executable: "{{ test_executable | default('podman') }}" |
| 244 |
- name: container1 |
| 245 |
state: absent |
| 246 |
executable: "{{ test_executable | default('podman') }}" |
| 247 |
register: deleted |
| 248 |
|
| 249 |
- name: Delete again containers (idempotency) |
| 250 |
containers.podman.podman_containers: |
| 251 |
containers: |
| 252 |
- name: container |
| 253 |
state: absent |
| 254 |
executable: "{{ test_executable | default('podman') }}" |
| 255 |
- name: container1 |
| 256 |
state: absent |
| 257 |
executable: "{{ test_executable | default('podman') }}" |
| 258 |
register: deleted_again |
| 259 |
|
| 260 |
- name: Check output is correct |
| 261 |
assert: |
| 262 |
that: |
| 263 |
- deleted is changed |
| 264 |
- deleted.containers is defined |
| 265 |
- deleted.containers == [] |
| 266 |
- "'deleted container' in deleted.actions" |
| 267 |
- "'deleted container1' in deleted.actions" |
| 268 |
- deleted_again is not changed |
| 269 |
- deleted_again.containers is defined |
| 270 |
- deleted_again.containers == [] |
| 271 |
- deleted_again.actions == [] |
| 272 |
fail_msg: Deleting stopped container test failed! |
| 273 |
success_msg: Deleting stopped container test passed! |
| 274 |
|
| 275 |
- name: Create containers, but don't run |
| 276 |
containers.podman.podman_containers: |
| 277 |
containers: |
| 278 |
- name: container |
| 279 |
image: alpine:3.7 |
| 280 |
state: stopped |
| 281 |
command: sleep 1d |
| 282 |
executable: "{{ test_executable | default('podman') }}" |
| 283 |
- name: container1 |
| 284 |
image: alpine:3.7 |
| 285 |
state: created |
| 286 |
command: sleep 1d |
| 287 |
executable: "{{ test_executable | default('podman') }}" |
| 288 |
register: created |
| 289 |
|
| 290 |
- name: Create containers, but don't run again |
| 291 |
containers.podman.podman_containers: |
| 292 |
containers: |
| 293 |
- name: container |
| 294 |
image: alpine:3.7 |
| 295 |
state: stopped |
| 296 |
command: sleep 1d |
| 297 |
executable: "{{ test_executable | default('podman') }}" |
| 298 |
- name: container1 |
| 299 |
image: alpine:3.7 |
| 300 |
state: created |
| 301 |
command: sleep 1d |
| 302 |
executable: "{{ test_executable | default('podman') }}" |
| 303 |
register: created_again |
| 304 |
|
| 305 |
- name: Check output is correct |
| 306 |
assert: |
| 307 |
that: |
| 308 |
- created is changed |
| 309 |
- created.containers is defined |
| 310 |
- created.containers != [] |
| 311 |
- not created.containers[0]['State']['Running'] |
| 312 |
- not created.containers[1]['State']['Running'] |
| 313 |
- "'created container' in created.actions" |
| 314 |
fail_msg: "Creating stopped container test failed!" |
| 315 |
success_msg: "Creating stopped container test passed!" |
| 316 |
|
| 317 |
- name: Delete created containers |
| 318 |
containers.podman.podman_containers: |
| 319 |
containers: |
| 320 |
- name: container |
| 321 |
state: absent |
| 322 |
executable: "{{ test_executable | default('podman') }}" |
| 323 |
- name: container1 |
| 324 |
state: absent |
| 325 |
executable: "{{ test_executable | default('podman') }}" |
| 326 |
|
| 327 |
- name: Start containers that were deleted |
| 328 |
containers.podman.podman_containers: |
| 329 |
containers: |
| 330 |
- name: container |
| 331 |
image: alpine:3.7 |
| 332 |
state: started |
| 333 |
command: sleep 1d |
| 334 |
executable: "{{ test_executable | default('podman') }}" |
| 335 |
- name: container1 |
| 336 |
image: alpine:3.7 |
| 337 |
state: started |
| 338 |
command: sleep 1d |
| 339 |
executable: "{{ test_executable | default('podman') }}" |
| 340 |
register: started |
| 341 |
|
| 342 |
- name: Check output is correct |
| 343 |
assert: |
| 344 |
that: |
| 345 |
- started.containers is defined |
| 346 |
- started.containers[0]['State']['Running'] |
| 347 |
- started.containers[1]['State']['Running'] |
| 348 |
- "'started container' in started.actions" |
| 349 |
- "'pulled image alpine:3.7' not in started.actions" |
| 350 |
|
| 351 |
- name: Delete started container |
| 352 |
containers.podman.podman_containers: |
| 353 |
containers: |
| 354 |
- name: container |
| 355 |
state: absent |
| 356 |
executable: "{{ test_executable | default('podman') }}" |
| 357 |
- name: container1 |
| 358 |
state: absent |
| 359 |
executable: "{{ test_executable | default('podman') }}" |
| 360 |
register: deleted |
| 361 |
|
| 362 |
- name: Delete again container (idempotency) |
| 363 |
containers.podman.podman_containers: |
| 364 |
containers: |
| 365 |
- name: container |
| 366 |
state: absent |
| 367 |
executable: "{{ test_executable | default('podman') }}" |
| 368 |
- name: container1 |
| 369 |
state: absent |
| 370 |
executable: "{{ test_executable | default('podman') }}" |
| 371 |
register: deleted_again |
| 372 |
|
| 373 |
- name: Check output is correct |
| 374 |
assert: |
| 375 |
that: |
| 376 |
- deleted is changed |
| 377 |
- deleted.containers is defined |
| 378 |
- deleted.containers == [] |
| 379 |
- "'deleted container' in deleted.actions" |
| 380 |
- "'deleted container1' in deleted.actions" |
| 381 |
- deleted_again is not changed |
| 382 |
- deleted_again.containers is defined |
| 383 |
- deleted_again.containers == [] |
| 384 |
- deleted_again.actions == [] |
| 385 |
fail_msg: Deleting started container test failed! |
| 386 |
success_msg: Deleting started container test passed! |
| 387 |
|
| 388 |
- name: Recreate container with parameters |
| 389 |
containers.podman.podman_containers: |
| 390 |
containers: |
| 391 |
- name: container |
| 392 |
executable: "{{ test_executable | default('podman') }}" |
| 393 |
image: docker.io/alpine:3.7 |
| 394 |
state: started |
| 395 |
command: sleep 1d |
| 396 |
recreate: true |
| 397 |
etc_hosts: |
| 398 |
host1: 127.0.0.1 |
| 399 |
host2: 127.0.0.1 |
| 400 |
annotation: |
| 401 |
this: "annotation_value" |
| 402 |
dns_servers: |
| 403 |
- 1.1.1.1 |
| 404 |
- 8.8.4.4 |
| 405 |
dns_search_domains: |
| 406 |
- example.com |
| 407 |
capabilities: |
| 408 |
- SYS_TIME |
| 409 |
- NET_ADMIN |
| 410 |
ports: |
| 411 |
- "9000:80" |
| 412 |
- "9001:8000" |
| 413 |
workdir: "/bin" |
| 414 |
env: |
| 415 |
FOO: bar=1 |
| 416 |
BAR: foo |
| 417 |
TEST: 1 |
| 418 |
BOOL: false |
| 419 |
label: |
| 420 |
somelabel: labelvalue |
| 421 |
otheralbe: othervalue |
| 422 |
volumes: |
| 423 |
- /tmp:/data |
| 424 |
- name: container1 |
| 425 |
executable: "{{ test_executable | default('podman') }}" |
| 426 |
image: docker.io/alpine:3.7 |
| 427 |
state: started |
| 428 |
command: sleep 1d |
| 429 |
recreate: true |
| 430 |
etc_hosts: |
| 431 |
host1: 127.0.0.1 |
| 432 |
host2: 127.0.0.1 |
| 433 |
annotation: |
| 434 |
this: "annotation_value" |
| 435 |
dns_servers: |
| 436 |
- 1.1.1.1 |
| 437 |
- 8.8.4.4 |
| 438 |
dns_search_domains: example.com |
| 439 |
capabilities: |
| 440 |
- SYS_TIME |
| 441 |
- NET_ADMIN |
| 442 |
ports: |
| 443 |
- "9002:80" |
| 444 |
- "9003:8000" |
| 445 |
workdir: "/bin" |
| 446 |
env: |
| 447 |
FOO: bar=1 |
| 448 |
BAR: foo |
| 449 |
TEST: 1 |
| 450 |
BOOL: false |
| 451 |
label: |
| 452 |
somelabel: labelvalue |
| 453 |
otheralbe: othervalue |
| 454 |
volumes: |
| 455 |
- /tmp:/data |
| 456 |
register: test |
| 457 |
|
| 458 |
- name: Check output is correct |
| 459 |
assert: |
| 460 |
that: |
| 461 |
- test is changed |
| 462 |
- test.containers is defined |
| 463 |
- test.containers != [] |
| 464 |
- test.containers[0]['State']['Running'] |
| 465 |
# test capabilities |
| 466 |
- "'CAP_SYS_TIME' in test.containers[0]['BoundingCaps']" |
| 467 |
- "'CAP_NET_ADMIN' in test.containers[0]['BoundingCaps']" |
| 468 |
# test annotations |
| 469 |
- test.containers[0]['Config']['Annotations']['this'] is defined |
| 470 |
- test.containers[0]['Config']['Annotations']['this'] == "annotation_value" |
| 471 |
# test DNS |
| 472 |
- >- |
| 473 |
(test.containers[0]['HostConfig']['Dns'] is defined and |
| 474 |
test.containers[0]['HostConfig']['Dns'] == ['1.1.1.1', '8.8.4.4']) or |
| 475 |
(test.containers[0]['HostConfig']['DNS'] is defined and |
| 476 |
test.containers[0]['HostConfig']['DNS'] == ['1.1.1.1', '8.8.4.4']) |
| 477 |
# test ports |
| 478 |
- test.containers[0]['NetworkSettings']['Ports']|length == 2 |
| 479 |
# test working dir |
| 480 |
- test.containers[0]['Config']['WorkingDir'] == "/bin" |
| 481 |
# test dns search |
| 482 |
- >- |
| 483 |
(test.containers[0]['HostConfig']['DnsSearch'] is defined and |
| 484 |
test.containers[0]['HostConfig']['DnsSearch'] == ['example.com']) or |
| 485 |
(test.containers[0]['HostConfig']['DNSSearch'] is defined and |
| 486 |
test.containers[0]['HostConfig']['DNSSearch'] == ['example.com']) |
| 487 |
# test environment variables |
| 488 |
- "'FOO=bar=1' in test.containers[0]['Config']['Env']" |
| 489 |
- "'BAR=foo' in test.containers[0]['Config']['Env']" |
| 490 |
- "'TEST=1' in test.containers[0]['Config']['Env']" |
| 491 |
- "'BOOL=False' in test.containers[0]['Config']['Env']" |
| 492 |
# test labels |
| 493 |
- test.containers[0]['Config']['Labels'] | length == 2 |
| 494 |
- test.containers[0]['Config']['Labels']['somelabel'] == "labelvalue" |
| 495 |
- test.containers[0]['Config']['Labels']['otheralbe'] == "othervalue" |
| 496 |
# test mounts |
| 497 |
- >- |
| 498 |
(test.containers[0]['Mounts'][0]['Destination'] is defined and |
| 499 |
'/data' in test.containers[0]['Mounts'] | map(attribute='Destination') | list) or |
| 500 |
(test.containers[0]['Mounts'][0]['destination'] is defined and |
| 501 |
'/data' in test.containers[0]['Mounts'] | map(attribute='destination') | list) |
| 502 |
- >- |
| 503 |
(test.containers[0]['Mounts'][0]['Source'] is defined and |
| 504 |
'/tmp' in test.containers[0]['Mounts'] | map(attribute='Source') | list) or |
| 505 |
(test.containers[0]['Mounts'][0]['source'] is defined and |
| 506 |
'/tmp' in test.containers[0]['Mounts'] | map(attribute='source') | list) |
| 507 |
fail_msg: Parameters container test failed! |
| 508 |
success_msg: Parameters container test passed! |
| 509 |
|
| 510 |
- name: Check basic idempotency of running container |
| 511 |
containers.podman.podman_containers: |
| 512 |
containers: |
| 513 |
- name: testidem |
| 514 |
image: docker.io/alpine |
| 515 |
state: started |
| 516 |
command: sleep 20m |
| 517 |
executable: "{{ test_executable | default('podman') }}" |
| 518 |
- name: testidem2 |
| 519 |
image: docker.io/alpine |
| 520 |
state: started |
| 521 |
command: sleep 21m |
| 522 |
executable: "{{ test_executable | default('podman') }}" |
| 523 |
- name: testidem3 |
| 524 |
image: docker.io/alpine |
| 525 |
state: started |
| 526 |
command: sleep 22m |
| 527 |
executable: "{{ test_executable | default('podman') }}" |
| 528 |
|
| 529 |
- name: Check basic idempotency of running container - run it again |
| 530 |
containers.podman.podman_containers: |
| 531 |
containers: |
| 532 |
- name: testidem |
| 533 |
image: docker.io/alpine |
| 534 |
state: present |
| 535 |
command: sleep 20m |
| 536 |
executable: "{{ test_executable | default('podman') }}" |
| 537 |
- name: testidem2 |
| 538 |
image: docker.io/alpine |
| 539 |
state: present |
| 540 |
command: sleep 21m |
| 541 |
executable: "{{ test_executable | default('podman') }}" |
| 542 |
- name: testidem3 |
| 543 |
image: docker.io/alpine |
| 544 |
state: present |
| 545 |
command: sleep 22m |
| 546 |
executable: "{{ test_executable | default('podman') }}" |
| 547 |
register: idem |
| 548 |
|
| 549 |
- name: Check that nothing was changed |
| 550 |
assert: |
| 551 |
that: |
| 552 |
- not idem.changed |
| 553 |
|
| 554 |
- name: Run changed container (with tty enabled) |
| 555 |
containers.podman.podman_containers: |
| 556 |
containers: |
| 557 |
- name: testidem |
| 558 |
image: docker.io/alpine |
| 559 |
state: present |
| 560 |
command: sleep 20m |
| 561 |
tty: true |
| 562 |
executable: "{{ test_executable | default('podman') }}" |
| 563 |
- name: testidem2 |
| 564 |
image: docker.io/alpine |
| 565 |
state: present |
| 566 |
command: sleep 21m |
| 567 |
executable: "{{ test_executable | default('podman') }}" |
| 568 |
- name: testidem3 |
| 569 |
image: docker.io/alpine |
| 570 |
state: present |
| 571 |
command: sleep 22m |
| 572 |
executable: "{{ test_executable | default('podman') }}" |
| 573 |
register: idem1 |
| 574 |
|
| 575 |
- name: Check that container is recreated when changed |
| 576 |
assert: |
| 577 |
that: |
| 578 |
- idem1 is changed |
| 579 |
|
| 580 |
- name: Run changed container without specifying an option, use defaults |
| 581 |
containers.podman.podman_containers: |
| 582 |
containers: |
| 583 |
- name: testidem |
| 584 |
image: docker.io/alpine |
| 585 |
state: present |
| 586 |
command: sleep 20m |
| 587 |
executable: "{{ test_executable | default('podman') }}" |
| 588 |
- name: testidem2 |
| 589 |
image: docker.io/alpine |
| 590 |
state: present |
| 591 |
command: sleep 21m |
| 592 |
executable: "{{ test_executable | default('podman') }}" |
| 593 |
- name: testidem3 |
| 594 |
image: docker.io/alpine |
| 595 |
state: present |
| 596 |
command: sleep 22m |
| 597 |
executable: "{{ test_executable | default('podman') }}" |
| 598 |
register: idem2 |
| 599 |
|
| 600 |
- name: Check that container is recreated when changed to default value |
| 601 |
assert: |
| 602 |
that: |
| 603 |
- idem2 is changed |
| 604 |
|
| 605 |
- name: Remove container |
| 606 |
containers.podman.podman_containers: |
| 607 |
containers: |
| 608 |
- name: testidem |
| 609 |
state: absent |
| 610 |
executable: "{{ test_executable | default('podman') }}" |
| 611 |
register: remove |
| 612 |
|
| 613 |
- name: Check podman_actions |
| 614 |
assert: |
| 615 |
that: |
| 616 |
- "'podman rm --force testidem' in remove.podman_actions" |
| 617 |
|
| 618 |
- name: Create a pod |
| 619 |
containers.podman.podman_pod: |
| 620 |
executable: "{{ test_executable | default('podman') }}" |
| 621 |
name: testidempod |
| 622 |
|
| 623 |
- name: Check basic idempotency of pod container |
| 624 |
containers.podman.podman_containers: |
| 625 |
containers: |
| 626 |
- name: testidem-pod |
| 627 |
image: docker.io/alpine |
| 628 |
state: present |
| 629 |
command: sleep 20m |
| 630 |
pod: "testidempod" |
| 631 |
executable: "{{ test_executable | default('podman') }}" |
| 632 |
- name: testidem-pod2 |
| 633 |
image: docker.io/alpine |
| 634 |
state: present |
| 635 |
command: sleep 20m |
| 636 |
pod: testidempod |
| 637 |
executable: "{{ test_executable | default('podman') }}" |
| 638 |
|
| 639 |
- name: Check basic idempotency of pod container - run it again |
| 640 |
containers.podman.podman_containers: |
| 641 |
containers: |
| 642 |
- name: testidem-pod |
| 643 |
image: alpine:latest |
| 644 |
state: present |
| 645 |
command: sleep 20m |
| 646 |
pod: testidempod |
| 647 |
executable: "{{ test_executable | default('podman') }}" |
| 648 |
- name: testidem-pod2 |
| 649 |
image: docker.io/alpine |
| 650 |
state: present |
| 651 |
command: sleep 20m |
| 652 |
pod: testidempod |
| 653 |
executable: "{{ test_executable | default('podman') }}" |
| 654 |
register: idem |
| 655 |
|
| 656 |
- name: Check that nothing was changed in pod containers |
| 657 |
assert: |
| 658 |
that: |
| 659 |
- not idem.changed |
| 660 |
|
| 661 |
- name: Run changed pod container (with tty enabled) |
| 662 |
containers.podman.podman_containers: |
| 663 |
containers: |
| 664 |
- name: testidem-pod |
| 665 |
image: alpine |
| 666 |
state: present |
| 667 |
command: sleep 20m |
| 668 |
tty: true |
| 669 |
pod: testidempod |
| 670 |
executable: "{{ test_executable | default('podman') }}" |
| 671 |
- name: testidem-pod2 |
| 672 |
image: alpine |
| 673 |
state: present |
| 674 |
command: sleep 20m |
| 675 |
pod: testidempod |
| 676 |
executable: "{{ test_executable | default('podman') }}" |
| 677 |
register: idem1 |
| 678 |
|
| 679 |
- name: Check that container is recreated when changed |
| 680 |
assert: |
| 681 |
that: |
| 682 |
- idem1 is changed |
| 683 |
|
| 684 |
- name: Remove container |
| 685 |
containers.podman.podman_containers: |
| 686 |
containers: |
| 687 |
- name: testidem-pod |
| 688 |
state: absent |
| 689 |
executable: "{{ test_executable | default('podman') }}" |
| 690 |
- name: testidem-pod2 |
| 691 |
state: absent |
| 692 |
executable: "{{ test_executable | default('podman') }}" |
| 693 |
|
| 694 |
always: |
| 695 |
- name: Delete all container leftovers from tests |
| 696 |
containers.podman.podman_container: |
| 697 |
executable: "{{ test_executable | default('podman') }}" |
| 698 |
name: "{{ item }}" |
| 699 |
state: absent |
| 700 |
loop: |
| 701 |
- "alpine:3.7" |
| 702 |
- "container" |
| 703 |
- "container1" |
| 704 |
- "container2" |
| 705 |
- "container3" |
| 706 |
- "container4" |
| 707 |
- "testidem" |
| 708 |
- "testidem1" |
| 709 |
- "testidem2" |
| 710 |
- "testidem3" |
| 711 |
- "testidem-pod" |
| 712 |
- "testidem-pod2" |
| 713 |
|
| 714 |
- name: Remove pod |
| 715 |
containers.podman.podman_pod: |
| 716 |
executable: "{{ test_executable | default('podman') }}" |
| 717 |
name: testidempod |
| 718 |
state: absent |
| 719 |
|
| 720 |
- name: Test containers module for root |
| 721 |
include_tasks: root-multi.yml |
| 722 |
vars: |
| 723 |
ansible_python_interpreter: "/usr/bin/python" |
| 724 |
args: |
| 725 |
apply: |
| 726 |
become: true |