diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 06:22:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 06:22:20 +0000 |
commit | 18bd2207b6c1977e99a93673a7be099e23f0f547 (patch) | |
tree | 40fd9e5913462a88be6ba24be6953383c5b39874 /ansible_collections/containers/podman/tests/integration | |
parent | Releasing progress-linux version 10.0.1+dfsg-1~progress7.99u1. (diff) | |
download | ansible-18bd2207b6c1977e99a93673a7be099e23f0f547.tar.xz ansible-18bd2207b6c1977e99a93673a7be099e23f0f547.zip |
Merging upstream version 10.1.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/containers/podman/tests/integration')
20 files changed, 2255 insertions, 36 deletions
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_all.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_all.yml index 023878349..0babf0395 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_all.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_all.yml @@ -162,10 +162,9 @@ command: 1h register: test14 -# We can't guess the default log path - name: Check info with default log opt path assert: - that: test14 is not changed + that: test14 is changed - name: Run container with all log-opts containers.podman.podman_container: @@ -238,8 +237,8 @@ that: - test15 is changed - test16 is not changed - - test17 is not changed - - test18 is not changed + - test17 is changed + - test18 is changed - test19 is changed - name: Run container with etc_hosts @@ -381,7 +380,7 @@ - name: Check info of second container with PID of container ID again assert: - that: test29 is not changed + that: test29 is changed - name: Remove dependent test container containers.podman.podman_container: diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_bool_list_dict.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_bool_list_dict.yml new file mode 100644 index 000000000..2d4771ceb --- /dev/null +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_bool_list_dict.yml @@ -0,0 +1,468 @@ +- name: Remove container + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + state: absent + +- name: Run container with boolean key-value type - 1 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + register: resultx1 + +- name: Run container with boolean key-value type - 2 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + register: resultx2 + +- name: Run container with boolean key-value type - 3 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + tls_verify: false + register: resultx3 + +- name: Run container with boolean key-value type - 4 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + tls_verify: false + register: resultx4 + +- name: Run container with boolean key-value type - 5 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + tls_verify: true + register: resultx5 + +- name: Run container with boolean key-value type - 6 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + tls_verify: true + register: resultx6 + +- name: Run container with boolean key-value type - 7 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + tls_verify: false + register: resultx7 + +- name: Run container with boolean key-value type - 8 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + # tls_verify: false + register: resultx8 + +- name: Run container with boolean key-value type - 9 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + tls_verify: true + register: resultx9 + +- name: Run container with boolean key-value type - 10 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + # tls_verify: true + register: resultx10 + +- name: Assert checks + assert: + that: + - resultx1.changed == true + - resultx2.changed == false + - resultx3.changed == true + - resultx4.changed == false + - resultx5.changed == true + - resultx6.changed == false + - resultx7.changed == true + - resultx8.changed == true + - resultx9.changed == true + - resultx10.changed == true + +- name: Remove container + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + state: absent + +- name: Run container with list type - 1 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + unsetenv: + - HOME + - TERM + - USER + register: resultq1 + +- name: Run container with list type - 2 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + unsetenv: + - HOME + - TERM + - USER + register: resultq2 + +- name: Run container with list type - 3 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + unsetenv: + - HOME + register: resultq3 + +- name: Run container with list type - 4 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + unsetenv: + - HOME + register: resultq4 + +- name: Run container with list type - 5 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + register: resultq5 + +- name: Run container with list type - 6 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + register: resultq6 + +- name: Run container with list type - 7 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + unsetenv: + - USER + register: resultq7 + +- name: Run container with list type - 8 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + unsetenv: + - USER + register: resultq8 + +- name: Run container with list type - 9 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + register: resultq9 + +- name: Assert checks + assert: + that: + - resultq1.changed == true + - resultq2.changed == false + - resultq3.changed == true + - resultq4.changed == false + - resultq5.changed == true + - resultq6.changed == false + - resultq7.changed == true + - resultq8.changed == false + - resultq9.changed == true + +- name: Remove container + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + state: absent + +- name: Run container with boolean trigger type - 1 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + register: resulty1 + +- name: Run container with boolean trigger type - 2 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + register: resulty2 + +- name: Run container with boolean trigger type - 3 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + no_healthcheck: false + register: resulty3 + +- name: Run container with boolean trigger type - 4 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + no_healthcheck: false + register: resulty4 + +- name: Run container with boolean trigger type - 5 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + no_healthcheck: true + register: resulty5 + +- name: Run container with boolean trigger type - 6 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + no_healthcheck: true + register: resulty6 + +- name: Run container with boolean trigger type - 7 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + no_healthcheck: false + register: resulty7 + +- name: Run container with boolean trigger type - 8 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + # no_healthcheck: false + register: resulty8 + +- name: Run container with boolean trigger type - 9 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + no_healthcheck: true + register: resulty9 + +- name: Run container with boolean trigger type - 10 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + # no_healthcheck: true + register: resulty10 + +- name: Assert checks + assert: + that: + - resulty1.changed == true + - resulty2.changed == false + - resulty3.changed == false + - resulty4.changed == false + - resulty5.changed == true + - resulty6.changed == false + - resulty7.changed == true + - resulty8.changed == false + - resulty9.changed == true + - resulty10.changed == true + + +- name: Remove container + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + state: absent + +- name: Run container with dict type - 1 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + log_opt: + max_size: 10m + tag: test + path: /var/log + register: resultv1 + +- name: Run container with dict type - 2 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + log_opt: + max_size: 10m + tag: test + path: /var/log + register: resultv2 + +- name: Run container with dict type - 3 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + log_opt: + max_size: 10m + register: resultv3 + +- name: Run container with dict type - 4 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + log_opt: + max_size: 10m + register: resultv4 + +- name: Run container with dict type - 5 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + register: resultv5 + +- name: Run container with dict type - 6 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + register: resultv6 + +- name: Run container with dict type - 7 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + log_opt: + tag: test + register: resultv7 + +- name: Run container with dict type - 8 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + log_opt: + tag: test + register: resultv8 + +- name: Run container with dict type - 9 + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "idempotency" + image: "{{ idem_image }}" + state: present + command: 1h + register: resultv9 + +- name: Assert checks + assert: + that: + - resultq1.changed == true + - resultq2.changed == false + - resultq3.changed == true + - resultq4.changed == false + - resultq5.changed == true + - resultq6.changed == false + - resultq7.changed == true + - resultq8.changed == false + - resultq9.changed == true diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_ports.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_ports.yml index 81b7baf06..29ad10c6d 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_ports.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_ports.yml @@ -33,7 +33,7 @@ - "4444:4444/tcp" - "1212:5555" - "8888:19191/udp" - - "1900:1900/udp" + - "19000:19000/udp" - "127.0.0.1:7671:7676/udp" - "127.0.0.1:12122:8876/udp" - "127.0.0.1:13122:8871/tcp" @@ -41,6 +41,10 @@ - "127.0.0.2:43423:8872/tcp" - "127.0.0.3:43423:8872" - "0.0.0.0:15674:7846" + - 127.0.0.1:20000-20010:20000-20010/udp + - 0.0.0.0:20000-20010:20000-20010/tcp + - "10000-10010:10000-10010/udp" + - "[::1]:3001-3003:3001-3003" register: test2 - name: check test2 @@ -57,7 +61,7 @@ - "4444:4444/tcp" - "1212:5555" - "8888:19191/udp" - - "1900:1900/udp" + - "19000:19000/udp" - "127.0.0.1:7671:7676/udp" - "127.0.0.1:12122:8876/udp" - "127.0.0.1:13122:8871/tcp" @@ -65,6 +69,10 @@ - "127.0.0.2:43423:8872/tcp" - "127.0.0.3:43423:8872" - "0.0.0.0:15674:7846" + - 127.0.0.1:20000-20010:20000-20010/udp + - 0.0.0.0:20000-20010:20000-20010/tcp + - "10000-10010:10000-10010/udp" + - "[::1]:3001-3003:3001-3003" register: test3 - name: check test3 @@ -95,7 +103,7 @@ - name: check test5 assert: - that: test5 is changed + that: test5 is not changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" @@ -149,7 +157,7 @@ - name: check test9 assert: - that: test9 is not changed + that: test9 is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" @@ -164,7 +172,7 @@ - name: check test9a assert: - that: test9a is not changed + that: test9a is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" @@ -213,7 +221,7 @@ - name: check test11 assert: - that: test11 is not changed + that: test11 is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" @@ -226,7 +234,7 @@ - name: check test11a assert: - that: test11a is not changed + that: test11a is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_stopsignal.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_stopsignal.yml index 98586aece..b806120d1 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_stopsignal.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_stopsignal.yml @@ -34,7 +34,20 @@ - name: check test2 assert: - that: test2 is not changed + that: test2 is changed + +- containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + image: "{{ idem_image }}" + name: idempotency + state: present + stop_signal: 9 + command: 1h + register: test2a + +- name: check test2a + assert: + that: test2a is not changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" @@ -46,7 +59,7 @@ - name: check test3 assert: - that: test3 is not changed + that: test3 is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" @@ -122,7 +135,7 @@ - name: check test9 assert: - that: test9 is not changed + that: test9 is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" @@ -184,7 +197,7 @@ - name: check test11 assert: - that: test11 is not changed + that: test11 is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_users.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_users.yml index 6be03bb1a..9b82ae332 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_users.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_users.yml @@ -34,7 +34,7 @@ - name: check test2 assert: - that: test2 is not changed + that: test2 is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" @@ -46,7 +46,7 @@ - name: check test3 assert: - that: test3 is not changed + that: test3 is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" @@ -122,7 +122,7 @@ - name: check test9 assert: - that: test9 is not changed + that: test9 is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_volumes.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_volumes.yml index 3fff4e34a..26e7040f8 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_volumes.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_volumes.yml @@ -126,7 +126,7 @@ - name: check test9 assert: - that: test9 is not changed + that: test9 is changed - name: Create volumes shell: | @@ -190,7 +190,7 @@ - name: check test13 assert: - that: test13 is not changed + that: test13 is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" @@ -253,3 +253,99 @@ - name: check test17 assert: that: test17 is not changed + +- containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + image: alpine + name: idempotency1 + state: present + command: sleep 1h + mounts: + - "type=bind,source=/tmp,destination=/tmp" + register: test18 + +- name: check test18 + assert: + that: test18 is changed + +- containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + image: alpine + name: idempotency1 + state: present + command: sleep 1h + mounts: + - "type=bind,source=/tmp,destination=/tmp" + register: test19 + +- name: check test19 + assert: + that: test19 is not changed + +- containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + image: alpine + name: idempotency1 + state: present + command: sleep 1h + mounts: + - "type=bind,source=/tmp,destination=/tmp" + - "type=bind,source=/var,destination=/var" + volumes: + - /opt:/data + - "local_volume2:/data2" + register: test20 + +- name: check test20 + assert: + that: test20 is changed + +- containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + image: alpine + name: idempotency1 + state: present + command: sleep 1h + mounts: + - "type=bind,source=/tmp,destination=/tmp" + - "type=bind,source=/var,destination=/var" + volumes: + - /opt:/data + - "local_volume2:/data2" + register: test21 + +- name: check test21 + assert: + that: test21 is not changed + +- containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + image: alpine + name: idempotency1 + state: present + command: sleep 1h + mounts: + - "type=bind,source=/tmp,destination=/tmp" + volumes: + - /opt:/data + register: test22 + +- name: check test22 + assert: + that: test22 is changed + +- containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + image: alpine + name: idempotency1 + state: present + command: sleep 1h + mounts: + - "type=bind,source=/tmp,destination=/tmp" + volumes: + - /opt:/data + register: test23 + +- name: check test23 + assert: + that: test23 is not changed diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_workdir.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_workdir.yml index ef1103188..f413090cc 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_workdir.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_workdir.yml @@ -34,13 +34,14 @@ - name: check test2 assert: - that: test2 is not changed + that: test2 is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" image: "{{ idem_image }}" name: idempotency state: present + workdir: /work command: 1h register: test3 @@ -122,7 +123,7 @@ - name: check test9 assert: - that: test9 is not changed + that: test9 is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" @@ -184,7 +185,7 @@ - name: check test11 assert: - that: test11 is not changed + that: test11 is changed - containers.podman.podman_container: executable: "{{ test_executable | default('podman') }}" diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml index 02b66d250..2d27906a5 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml @@ -45,6 +45,7 @@ - name: Test idempotency of systemd generation include_tasks: idem_systemd.yml + when: podman_version | int > 3 - name: Test idempotency of other settings include_tasks: idem_all.yml diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/root-podman.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/root-podman.yml index f41587367..0d9032754 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/root-podman.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/root-podman.yml @@ -162,7 +162,7 @@ - name: Check that it is recreated assert: that: - - info7 is not changed + - info7 is changed - name: Run container with publishing ports and ipv6 containers.podman.podman_container: @@ -178,6 +178,7 @@ - "127.0.0.1:7671:7676/udp" - "127.0.0.3:43423:8872" - "[::1]:34523:35425" + - "40001-40010" register: info8 - name: Check that it is recreated @@ -199,6 +200,7 @@ - "127.0.0.1:7671:7676/udp" - "127.0.0.3:43423:8872" - "[::1]:34523:35425" + - "40001-40010" register: info9 - name: Check that it is recreated diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml index 3c16efac2..74c21ff4d 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml @@ -109,7 +109,7 @@ that: - info5 is changed - - when: podman_version < 5 + - when: podman_version | int < 5 name: Run container tasks with slirp4netns options before v5 block: - name: Run container with slirp4netns options @@ -161,7 +161,7 @@ - info8 is changed - - when: podman_version >= 5 + - when: podman_version | int >= 5 name: Run container tasks with pasta options for v5 and later block: - name: Run container with pasta options diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/idem_push.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/idem_push.yml new file mode 100644 index 000000000..064ce8fc4 --- /dev/null +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/idem_push.yml @@ -0,0 +1,534 @@ +--- +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + ignore_errors: true + register: img_result1 + +- name: Check outputs + assert: + that: + - img_result1 is failed + - "'Destination must be a full URL or path to a directory' in img_result1.msg" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + ignore_errors: true + register: img_result2 + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result2.stderr" + - "'push quay.io/testing/testimage:latest quay.io/testing/testimage:latest' in img_result2.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage:draft + pull: false + push: true + ignore_errors: true + register: img_result2a + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result2a.stderr" + - "'push quay.io/testing/testimage:draft quay.io/testing/testimage:draft' in img_result2a.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: quay.io/testing/testimage + ignore_errors: true + register: img_result3 + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result3.stderr" + - "'push quay.io/testing/testimage:latest quay.io/testing/testimage' in img_result3.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage:draft + pull: false + push: true + push_args: + dest: quay.io/testing/testimage + ignore_errors: true + register: img_result3a + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result3a.stderr" + - "'push quay.io/testing/testimage:draft quay.io/testing/testimage' in img_result3a.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage:draft + pull: false + push: true + push_args: + dest: quay.io/testing/testimage:nodraft + ignore_errors: true + register: img_result3b + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result3b.stderr" + - "'push quay.io/testing/testimage:draft quay.io/testing/testimage:nodraft' in img_result3b.actions" + +- containers.podman.podman_image: + name: testimage2 + tag: testtag + pull: false + push: true + push_args: + dest: quay.io/testing/testimage + ignore_errors: true + register: img_result4 + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result4.stderr" + - "'push testimage2:testtag quay.io/testing/testimage' in img_result4.actions" + +- containers.podman.podman_image: + name: testimage2 + tag: testtag + pull: false + push: true + push_args: + dest: quay.io/testing + ignore_errors: true + register: img_result4a + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result4a.stderr" + - "'push testimage2:testtag quay.io/testing/testimage2:testtag' in img_result4a.actions" + +- containers.podman.podman_image: + name: testimage2:testtag + pull: false + push: true + push_args: + dest: quay.io/testing/ + ignore_errors: true + register: img_result4b + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result4b.stderr" + - "'push testimage2:testtag quay.io/testing/testimage2:testtag' in img_result4b.actions" + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: quay.io/testing/ + ignore_errors: true + register: img_result4c + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result4c.stderr" + - "'push testimage2:latest quay.io/testing/testimage2:latest' in img_result4c.actions" + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: /tmp/testimage-dir + transport: dir + ignore_errors: true + register: img_result5 + +- name: Check outputs + assert: + that: + - img_result5 is changed + - "'push testimage2:latest dir:/tmp/testimage-dir' in img_result5.actions" + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: dir:/tmp/testimage-dir1 + ignore_errors: true + register: img_result6 + +- name: Check outputs + assert: + that: + - img_result6 is changed + - "'push testimage2:latest dir:/tmp/testimage-dir1' in img_result6.actions" + +- name: Remove directories + file: + path: "{{ item }}" + state: absent + loop: + - /tmp/test-docker-arch + - /tmp/test-docker-arch1 + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: /tmp/test-docker-arch + transport: docker-archive + ignore_errors: true + register: img_result7 + +- name: Check outputs + assert: + that: + - img_result7 is changed + - "'push testimage2:latest docker-archive:/tmp/test-docker-arch' in img_result7.actions" + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: docker-archive:/tmp/test-docker-arch1 + ignore_errors: true + register: img_result8 + +- name: Check outputs + assert: + that: + - img_result8 is changed + - "'push testimage2:latest docker-archive:/tmp/test-docker-arch1' in img_result8.actions" + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: /tmp/test-oci-arch + transport: oci-archive + ignore_errors: true + register: img_result9 + +- name: Check outputs + assert: + that: + - img_result9 is changed + - "'push testimage2:latest oci-archive:/tmp/test-oci-arch' in img_result9.actions" + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: oci-archive:/tmp/test-oci-arch1 + ignore_errors: true + register: img_result10 + +- name: Check outputs + assert: + that: + - img_result10 is changed + - "'push testimage2:latest oci-archive:/tmp/test-oci-arch1' in img_result10.actions" + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: quay.io/testing/testimage1 + transport: docker + ignore_errors: true + register: img_result11 + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result11.stderr" + - "'push testimage2:latest docker://quay.io/testing/testimage1' in img_result11.actions" + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: docker://quay.io/testing/testimage22 + ignore_errors: true + register: img_result12 + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result12.stderr" + - "'push testimage2:latest docker://quay.io/testing/testimage22' in img_result12.actions" + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: dockerimage + transport: docker-daemon + ignore_errors: true + register: img_result13 + +- name: Check outputs + assert: + that: + - img_result13 is changed + - "'push testimage2:latest docker-daemon:dockerimage:latest' in img_result13.actions" + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: docker-daemon:dockerimage2 + ignore_errors: true + register: img_result14 + +- name: Check outputs + assert: + that: + - img_result14 is failure + - "'push testimage2:latest docker-daemon:dockerimage2' in img_result14.actions" + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: dockerimage:tagged1 + transport: docker-daemon + ignore_errors: true + register: img_result15 + +- name: Check outputs + assert: + that: + - img_result15 is success + - "'push testimage2:latest docker-daemon:dockerimage:tagged1' in img_result15.actions" + +- containers.podman.podman_image: + name: testimage2 + pull: false + push: true + push_args: + dest: docker-daemon:dockerimage:tagged + ignore_errors: true + register: img_result16 + +- name: Check outputs + assert: + that: + - img_result16 is success + - "'push testimage2:latest docker-daemon:dockerimage:tagged' in img_result16.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: /tmp/testimage-dir25 + transport: dir + ignore_errors: true + register: img_result17 + +- name: Check outputs + assert: + that: + - img_result17 is success + - "'push quay.io/testing/testimage:latest dir:/tmp/testimage-dir25' in img_result17.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: dir:/tmp/testimage-dir15 + ignore_errors: true + register: img_result18 + +- name: Check outputs + assert: + that: + - img_result18 is success + - "'push quay.io/testing/testimage:latest dir:/tmp/testimage-dir15' in img_result18.actions" + +- name: Remove directories for docker-archive + file: + path: "{{ item }}" + state: absent + loop: + - /tmp/test-docker-arch5 + - /tmp/test-docker-arch15 + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: /tmp/test-docker-arch5 + transport: docker-archive + ignore_errors: true + register: img_result19 + +- name: Check outputs + assert: + that: + - img_result19 is success + - "'push quay.io/testing/testimage:latest docker-archive:/tmp/test-docker-arch5' in img_result19.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: docker-archive:/tmp/test-docker-arch15 + ignore_errors: true + register: img_result20 + +- name: Check outputs + assert: + that: + - img_result20 is success + - "'push quay.io/testing/testimage:latest docker-archive:/tmp/test-docker-arch15' in img_result20.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: /tmp/test-oci-arch5 + transport: oci-archive + ignore_errors: true + register: img_result21 + +- name: Check outputs + assert: + that: + - img_result21 is success + - "'push quay.io/testing/testimage:latest oci-archive:/tmp/test-oci-arch5' in img_result21.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: oci-archive:/tmp/test-oci-arch15 + ignore_errors: true + register: img_result22 + +- name: Check outputs + assert: + that: + - img_result22 is success + - "'push quay.io/testing/testimage:latest oci-archive:/tmp/test-oci-arch15' in img_result22.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: quay.io/testing/testimage5 + transport: docker + ignore_errors: true + register: img_result23 + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result23.stderr" + - "'push quay.io/testing/testimage:latest docker://quay.io/testing/testimage5' in img_result23.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: docker://quay.io/testing/testimage22 + ignore_errors: true + register: img_result24 + +- name: Check outputs + assert: + that: + - "'authentication required' in img_result24.stderr" + - "'push quay.io/testing/testimage:latest docker://quay.io/testing/testimage22' in img_result24.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: dockerimage5 + transport: docker-daemon + ignore_errors: true + register: img_result25 + +- name: Check outputs + assert: + that: + - img_result25 is success + - "'push quay.io/testing/testimage:latest docker-daemon:dockerimage5:latest' in img_result25.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: docker-daemon:dockerimage25 + ignore_errors: true + register: img_result26 + +- name: Check outputs + assert: + that: + - img_result26 is failed + - "'push quay.io/testing/testimage:latest docker-daemon:dockerimage25' in img_result26.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: dockerimage:tagged15 + transport: docker-daemon + ignore_errors: true + register: img_result27 + +- name: Check outputs + assert: + that: + - img_result27 is success + - "'push quay.io/testing/testimage:latest docker-daemon:dockerimage:tagged15' in img_result27.actions" + +- containers.podman.podman_image: + name: quay.io/testing/testimage + pull: false + push: true + push_args: + dest: docker-daemon:dockerimage:tagged5 + ignore_errors: true + register: img_result28 + +- name: Check outputs + assert: + that: + - img_result28 is success + - "'push quay.io/testing/testimage:latest docker-daemon:dockerimage:tagged5' in img_result28.actions" diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml index 96133b9da..dca1ee53e 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml @@ -209,15 +209,34 @@ register: oci_build3 ignore_errors: true - - name: Build OCI image, point to location of Containerfile + - name: Build OCI image, point to location of Containerfile without path containers.podman.podman_image: executable: "{{ test_executable | default('podman') }}" name: testimage2 - path: /var/tmp/build/subdir + state: build build: file: /var/tmp/build/Dockerfile register: oci_build4 + - name: Build OCI image, point to location of Containerfile and path + containers.podman.podman_image: + executable: "{{ test_executable | default('podman') }}" + name: testimage3 + path: /var/tmp/build + build: + file: /var/tmp/build/Dockerfile + register: oci_build5 + + - name: Build OCI image with no Containerfile and path + containers.podman.podman_image: + executable: "{{ test_executable | default('podman') }}" + name: testimage5x + state: build + build: + format: oci + register: oci_build6 + ignore_errors: true + - name: Inspect first image containers.podman.podman_image_info: executable: "{{ test_executable | default('podman') }}" @@ -237,7 +256,9 @@ - oci_build2 is not changed - oci_build3 is not changed - oci_build3 is failed - - oci_build4 is changed + - oci_build4 is success + - oci_build5 is success + - oci_build6 is failed - "'localhost/testimage:latest' in testimage_info.images[0]['RepoTags'][0]" - "'localhost/testimage2:latest' in testimage2_info.images[0]['RepoTags'][0]" - "'no such file or directory' in oci_build3.msg" @@ -329,6 +350,72 @@ - item.Architecture == "arm" loop: "{{ imageinfo_arch.images }}" + - name: Build Docker image + containers.podman.podman_image: + executable: "{{ test_executable | default('podman') }}" + name: quay.io/testing/testimage + path: /var/tmp/build + register: build_image1 + + - name: Build Docker image - 2 + containers.podman.podman_image: + executable: "{{ test_executable | default('podman') }}" + name: quay.io/testing/testimage:draft + path: /var/tmp/build + + - name: Build Docker image + containers.podman.podman_image: + executable: "{{ test_executable | default('podman') }}" + name: testimage2:testtag + path: /var/tmp/build + register: build_image2 + + - name: Build image from a given Containerfile + containers.podman.podman_image: + executable: "{{ test_executable | default('podman') }}" + name: testimage2:customfile + path: "{{ playbook_dir }}" + build: + container_file: |- + FROM quay.io/coreos/alpine-sh + RUN echo "Hello World" > /tmp/hello.txt + register: build_custom1 + + - name: Build image from a given Containerfile w/o path + containers.podman.podman_image: + executable: "{{ test_executable | default('podman') }}" + name: testimage2:customfile2 + state: build + build: + container_file: |- + FROM quay.io/coreos/alpine-sh + RUN echo "Hello2 World" > /tmp/hello2.txt + force: true + register: build_custom2 + + - name: Build image from a given Containerfile and file (fail) + containers.podman.podman_image: + executable: "{{ test_executable | default('podman') }}" + name: testimage2:failme + state: build + build: + container_file: |- + FROM quay.io/coreos/alpine-sh + RUN echo "Hello2 World" > /tmp/hello2.txt + file: /var/tmp/build/Dockerfile + force: true + register: fail_custom_image + ignore_errors: true + + - name: Check if image was built properly + assert: + that: + - build_custom1 is changed + - build_custom2 is changed + - fail_custom_image is failed + + - include_tasks: idem_push.yml + - name: Create a Quadlet for image with filename containers.podman.podman_image: executable: "{{ test_executable | default('podman') }}" @@ -469,4 +556,8 @@ - quay.io/coreos/etcd:v3.3.11 - localhost/testimage - localhost/testimage2 + - localhost/testimage2:testtag + - localhost/testimage3 - localhost/dockerimage + - quay.io/testing/testimage + - quay.io/testing/testimage:draft diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml index 272ac6b43..4bfb4b0c1 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml @@ -328,20 +328,20 @@ that: - info16 is not changed - - name: Create network with IPv6 'exploded' + - name: Create network with IPv6 'exploded' - dual stack containers.podman.podman_network: executable: "{{ test_executable | default('podman') }}" name: "{{ network_name }}" ipv6: true - subnet: fd4f:552c:830f:0000::/64 + subnet: fd4f:552c:830f::/64 state: present - - name: Create network with IPv6 'exploded' again + - name: Create network with IPv6 'exploded' - dual stack again containers.podman.podman_network: executable: "{{ test_executable | default('podman') }}" name: "{{ network_name }}" ipv6: true - subnet: fd4f:552c:830f:0000::/64 + subnet: fd4f:552c:830f::/64 state: present register: info17 @@ -350,6 +350,358 @@ that: - info17 is not changed + - name: Create network with DNS + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + state: present + dns: + - 1.1.1.1 + - 2.2.2.2 + register: resultn2 + + - name: Check output - Create network with DNS + assert: + that: + - resultn2 is changed + + - name: Create network with DNS again + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + state: present + dns: + - 1.1.1.1 + - 2.2.2.2 + register: resultn3 + + - name: Check output - Create network with DNS again + assert: + that: + - resultn3 is not changed + + - name: Create network with DNS - different + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + state: present + dns: + - 1.1.1.1 + register: resultn4 + + - name: Check output - Create network with DNS - different + assert: + that: + - resultn4 is changed + + - name: Create network with routes + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + state: present + route: + - 1.1.1.1/32,2.2.2.2 + - 3.3.3.0/24,4.4.4.4,240 + - 7.7.0.0/16,9.9.9.9,100 + register: resultn5 + + - name: Check output - Create network with routes + assert: + that: + - resultn5 is changed + + - name: Create network with routes again + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + state: present + route: + - 1.1.1.1/32,2.2.2.2 + - 3.3.3.0/24,4.4.4.4,240 + - 7.7.0.0/16,9.9.9.9,100 + register: resultn6 + + - name: Check output - Create network with routes again + assert: + that: + - resultn6 is not changed + + - name: Create network with routes - different + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + state: present + route: + - 1.1.1.1/32,2.2.2.2 + - 3.3.3.0/24,4.4.4.4,280 + register: resultn7 + + - name: Check output - Create network with routes - different + assert: + that: + - resultn7 is changed + + - name: Create network with IPAM driver none + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + state: present + ipam_driver: none + register: resultn8 + + - name: Check output - Create network with IPAM driver none + assert: + that: + - resultn8 is changed + + - name: Create network with IPAM driver none again + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + state: present + ipam_driver: none + register: resultn9 + + - name: Check output - Create network with IPAM driver none again + assert: + that: + - resultn9 is not changed + + - name: Create network without IPAM driver + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + state: present + register: resultn10 + + - name: Check output - Create network without IPAM driver + assert: + that: + - resultn10 is not changed + + - name: Create network with IPAM driver host-local + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + state: present + ipam_driver: "host-local" + register: resultn11 + + - name: Check output - Create network with IPAM driver host-local + assert: + that: + - resultn11 is changed + + - name: Delete network + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + state: absent + + - name: Create a network with multiple subnets + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + net_config: + - subnet: 10.44.44.0/24 + gateway: 10.44.44.44 + ip_range: 10.44.44.128/30 + - subnet: 10.22.22.0/24 + gateway: 10.22.22.244 + - subnet: 10.11.1.0/24 + gateway: 10.11.1.33 + + - name: Create a network with multiple subnets again + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + net_config: + - subnet: 10.44.44.0/24 + gateway: 10.44.44.44 + ip_range: 10.44.44.128/30 + - subnet: 10.22.22.0/24 + gateway: 10.22.22.244 + - subnet: 10.11.1.0/24 + gateway: 10.11.1.33 + register: net2conf + + - name: Check output - Create a network with multiple subnets again + assert: + that: + - net2conf is not changed + + - name: Create a network with multiple subnets - different + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + net_config: + - subnet: 10.44.44.0/24 + gateway: 10.44.44.44 + ip_range: 10.44.44.128/30 + - subnet: 10.11.12.0/24 + gateway: 10.11.12.33 + register: net2conf1 + + - name: Check output - Create a network with multiple subnets - different + assert: + that: + - net2conf1 is changed + + - name: Create a network with multiple subnets - different gateway + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + net_config: + - subnet: 10.44.44.0/24 + gateway: 10.44.44.41 + ip_range: 10.44.44.128/30 + - subnet: 10.11.12.0/24 + gateway: 10.11.12.33 + register: net2conf2 + + - name: Check output - Create a network with multiple subnets - different gateway + assert: + that: + - net2conf2 is changed + + - name: Create a network with multiple subnets again - same + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + net_config: + - subnet: 10.44.44.0/24 + gateway: 10.44.44.41 + ip_range: 10.44.44.128/30 + - subnet: 10.11.12.0/24 + gateway: 10.11.12.33 + register: net2conf3 + + - name: Check output - Create a network with multiple subnets again - same + assert: + that: + - net2conf3 is not changed + + - name: Create a network with single subnet + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + subnet: 10.44.44.0/24 + gateway: 10.44.44.41 + register: net2conf4 + + - name: Check output - Create a network with single subnet + assert: + that: + - net2conf4 is changed + + - name: Create a network with single subnet - again + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + subnet: 10.44.44.0/24 + gateway: 10.44.44.41 + register: net2conf5 + + - name: Check output - Create a network with single subnet - again + assert: + that: + - net2conf5 is not changed + + - name: Create a network with single subnet and changed gateway + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + subnet: 10.44.44.0/24 + gateway: 10.44.44.42 + register: net2conf6 + + - name: Check output - Create a network with single subnet and changed gateway + assert: + that: + - net2conf6 is changed + + - name: Create a network with single subnet - without gateway + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + subnet: 10.44.44.0/24 + register: net2conf7 + + - name: Check output - Create a network with single subnet - without gateway + assert: + that: + - net2conf7 is not changed + + - name: Create a network with multiple subnets + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + net_config: + - subnet: 10.44.44.0/24 + gateway: 10.44.44.44 + ip_range: 10.44.44.128/30 + - subnet: 10.22.22.0/24 + gateway: 10.22.22.244 + - subnet: 10.17.1.0/24 + gateway: 10.17.1.33 + + - name: Create a network with multiple subnets again + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + net_config: + - subnet: 10.44.44.0/24 + gateway: 10.44.44.44 + ip_range: 10.44.44.128/30 + - subnet: 10.22.22.0/24 + gateway: 10.22.22.244 + - subnet: 10.17.1.0/24 + gateway: 10.17.1.33 + register: net2conf + + - name: Check output - Create a network with multiple subnets again + assert: + that: + - net2conf is not changed + + - name: Create a IPv6 network with multiple subnets + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + net_config: + - subnet: 2002:db8:1::/64 + gateway: 2002:db8:1::12 + ip_range: 2002:db8:1::128/68 + - subnet: 2004:db9:1::/64 + gateway: 2004:db9:1::15 + - subnet: 10.15.11.0/24 + gateway: 10.15.11.124 + register: net6conf + + - name: Check output - Create a network with multiple subnets again + assert: + that: + - net6conf is changed + + - name: Create a IPv6 network with multiple subnets again + containers.podman.podman_network: + executable: "{{ test_executable | default('podman') }}" + name: "{{ network_name }}" + net_config: + - subnet: 2002:db8:1::/64 + gateway: 2002:db8:1::12 + ip_range: 2002:db8:1::128/68 + - subnet: 2004:db9:1::/64 + gateway: 2004:db9:1::15 + - subnet: 10.15.11.0/24 + gateway: 10.15.11.124 + register: net6conf1 + + - name: Check output - Create a network with multiple subnets again + assert: + that: + - net6conf1 is not changed + - name: Create a Quadlet for network with filename containers.podman.podman_network: executable: "{{ test_executable | default('podman') }}" diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/idempotency.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/idempotency.yml new file mode 100644 index 000000000..26c3bd8f9 --- /dev/null +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/idempotency.yml @@ -0,0 +1,363 @@ +- name: Test podman pod idempotency + block: + + - name: Delete all pods leftovers from tests + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: "{{ item }}" + state: absent + loop: + - "podidem1" + - "podidem2" + + - name: Delete all container leftovers from tests + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "{{ item }}" + state: absent + loop: + - "container1" + - "container2" + + - name: Create pod + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem1 + state: created + register: podidem1_info + + - name: Check info + assert: + that: + - podidem1_info is changed + - >- + (podidem1_info.pod['State']['status'] is defined and + podidem1_info.pod['State']['status'] == 'Created') or + (podidem1_info.pod['State']['status'] is not defined and + podidem1_info.pod['State'] == 'Created') + + - name: Create pod again + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem1 + state: created + register: podidem1_info2 + + - name: Check info + assert: + that: + - podidem1_info2 is not changed + + - name: Start pod + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem1 + state: started + register: podidem1_info3 + + - name: Check info + assert: + that: + - podidem1_info3 is changed + - >- + (podidem1_info3.pod['State']['status'] is defined and + podidem1_info3.pod['State']['status'] == 'Running') or + (podidem1_info3.pod['State']['status'] is not defined and + podidem1_info3.pod['State'] == 'Running') + + - name: Start pod again + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem1 + state: started + register: podidem1_info4 + + - name: Check info + assert: + that: + - podidem1_info4 is not changed + + - name: Stop pod + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem1 + state: stopped + register: podidem1_info5 + + - name: Check info + assert: + that: + - podidem1_info5 is changed + + - name: Stop pod again + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem1 + state: stopped + register: podidem1_info6 + + - name: Check info + assert: + that: + - podidem1_info6 is not changed + + - name: Create stopped pod again + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem1 + state: created + register: podidem1_info7 + + - name: Check info + assert: + that: + - podidem1_info7 is not changed + + - name: Create pod with multiple options and containers + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem2 + state: created + infra: true + network: host + share: net + userns: auto + security_opt: + - seccomp=unconfined + - apparmor=unconfined + hostname: mypod + dns: + - 1.1.1.1 + volumes: + - /tmp:/tmp/:ro + - /var/run/://var/run + label: + key: cval + otherkey: kddkdk + somekey: someval + add_host: + - "google:5.5.5.5" + register: podidem2_info + + - name: Check info + assert: + that: + - podidem2_info is changed + + - name: Create same pod + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem2 + state: created + infra: true + network: host + share: net + userns: auto + security_opt: + - seccomp=unconfined + - apparmor=unconfined + hostname: mypod + dns: + - 1.1.1.1 + volumes: + - /tmp:/tmp/:ro + - /var/run/://var/run + label: + key: cval + otherkey: kddkdk + somekey: someval + add_host: + - "google:5.5.5.5" + register: podidem2_info2 + + - name: Check info + assert: + that: + - podidem2_info2 is not changed + + - name: Change the pod + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem2 + state: created + infra: true + network: host + share: net + userns: auto + security_opt: + - seccomp=unconfined + - apparmor=unconfined + hostname: mypod + dns: + - 1.1.1.2 + volumes: + - /tmp:/tmp/:ro + - /var/run/://var/run + label: + key: cval + otherkey: kddkdk + somekey: someval + add_host: + - "google:5.5.5.5" + register: podidem2_info3 + + - name: Check info + assert: + that: + - podidem2_info3 is changed + + - name: Start the pod + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem2 + state: started + infra: true + network: host + share: net + userns: auto + security_opt: + - seccomp=unconfined + - apparmor=unconfined + hostname: mypod + dns: + - 1.1.1.2 + volumes: + - /tmp:/tmp/:ro + - /var/run/://var/run + label: + key: cval + otherkey: kddkdk + somekey: someval + add_host: + - "google:5.5.5.5" + + - name: Configure and start the pod again + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem2 + state: started + infra: true + network: host + share: net + userns: auto + security_opt: + - seccomp=unconfined + - apparmor=unconfined + hostname: mypod + dns: + - 1.1.1.2 + volumes: + - /tmp:/tmp/:ro + - /var/run/://var/run + label: + key: cval + otherkey: kddkdk + somekey: someval + add_host: + - "google:5.5.5.5" + register: podidem2_info4 + + - name: Check info + assert: + that: + - podidem2_info4 is not changed + + - name: Remove pod + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem2 + state: absent + + - name: Create a pod with parameters - created + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem2 + state: created + infra: true + network: host + share: net + userns: auto + security_opt: + - seccomp=unconfined + - apparmor=unconfined + hostname: mypod + dns: + - 1.1.1.2 + volumes: + - /tmp:/tmp/:ro + label: + key: cval + otherkey: kddkdk + somekey: someval + add_host: + - "google:5.5.5.5" + register: pod1_set + + - name: Create containers + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "{{ item }}" + state: created + pod: podidem2 + image: alpine + command: sleep 1h + loop: + - "container1" + - "container2" + + - name: Start pod + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: podidem2 + state: started + infra: true + network: host + share: net + userns: auto + security_opt: + - seccomp=unconfined + - apparmor=unconfined + hostname: mypod + dns: + - 1.1.1.2 + volumes: + - /tmp:/tmp/:ro + label: + key: cval + otherkey: kddkdk + somekey: someval + add_host: + - "google:5.5.5.5" + register: pod2_set + + - name: Check info for pod creation + assert: + that: + - pod1_set is changed + - pod2_set is changed + - pod1_set.pod['State'] == 'Created' + - pod1_set.pod['Containers'][0]['State'] == 'created' + - pod2_set.pod['State'] == 'Running' + - pod2_set.pod['Containers'][0]['State'] == 'running' + - pod2_set.pod['Containers'][1]['State'] == 'running' + - pod2_set.pod['Containers'][2]['State'] == 'running' + + always: + + - name: Delete all pods leftovers from tests + containers.podman.podman_pod: + executable: "{{ test_executable | default('podman') }}" + name: "{{ item }}" + state: absent + loop: + - "podidem1" + - "podidem1" + + - name: Delete all container leftovers from tests + containers.podman.podman_container: + executable: "{{ test_executable | default('podman') }}" + name: "{{ item }}" + state: absent + loop: + - "container1" + - "container2" diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml index cb455aa23..c148f9a99 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml @@ -1010,6 +1010,8 @@ subuidname: username1 userns: auto publish: 8000:8001 + sysctl: + "net.ipv4.ip_forward": 1 add_host: - host1 volume: @@ -1052,6 +1054,7 @@ - "PodmanArgs=--subuidname username1" - "PodmanArgs=--userns auto" - "PodmanArgs=--add-host host1" + - "PodmanArgs=--sysctl net.ipv4.ip_forward=1" - "Label=somelabel=labelvalue" - "WantedBy=default.target" loop_control: @@ -1075,6 +1078,8 @@ subuidname: username1 userns: auto publish: 8000:8001 + sysctl: + "net.ipv4.ip_forward": 1 add_host: - host1 volume: @@ -1103,6 +1108,8 @@ subuidname: username1 userns: auto publish: 8000:8001 + sysctl: + "net.ipv4.ip_forward": 1 add_host: - host1 volume: @@ -1146,6 +1153,9 @@ - "container1" - "container2" +- name: Test idempotency rootless pods + include_tasks: idempotency.yml + - name: Test idempotency for root pods include_tasks: root-pod.yml vars: diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/resource-limit.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/resource-limit.yml index 8727d6e50..83b673af1 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/resource-limit.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/resource-limit.yml @@ -8,6 +8,7 @@ cpuset_mems: '0-1' cpu_shares: 1024 device_write_bps: ['/dev/zero:1048576'] + shm_size: 1G - name: Create pod for limiting resources containers.podman.podman_pod: @@ -18,6 +19,7 @@ cpuset_mems: "{{ limit.cpuset_mems }}" cpu_shares: "{{ limit.cpu_shares }}" device_write_bps: "{{ limit.device_write_bps }}" + shm_size: "{{ limit.shm_size }}" - name: Get information on pod for limiting resources containers.podman.podman_pod_info: diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/root-pod.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/root-pod.yml index 968ec2cf3..557d0854f 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/root-pod.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/root-pod.yml @@ -132,6 +132,7 @@ - "127.0.0.2:7671:7676/udp" - "127.0.0.1:13122:8871/tcp" - "127.0.0.1:43423:8872" + - "0.0.0.0:44444:44445" - "[::1]:8743:8745" register: pod8_info @@ -152,6 +153,7 @@ - "127.0.0.2:7671:7676/udp" - "127.0.0.1:13122:8871/tcp" - "127.0.0.1:43423:8872" + - "0.0.0.0:44444:44445" - "[::1]:8743:8745" register: pod9_info diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_search/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_search/tasks/main.yml new file mode 100644 index 000000000..66c5ebda0 --- /dev/null +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_search/tasks/main.yml @@ -0,0 +1,50 @@ +- name: Test podman_search + block: + + - name: Search for an invalid image + containers.podman.podman_search: + term: invalidtermnope + executable: "{{ test_executable | default('podman') }}" + register: info_0 + + - name: Check results for no matching images + assert: + that: + - info_0.images | length == 0 + + - name: Search for matching images + containers.podman.podman_search: + term: etcd + executable: "{{ test_executable | default('podman') }}" + register: info_1 + + - name: Check results for matching images + assert: + that: + - info_1.images | length > 0 + + - name: Search for a specific image + containers.podman.podman_search: + term: registry.access.redhat.com/rhel7/rsyslog + executable: "{{ test_executable | default('podman') }}" + register: info_2 + + - name: Check result for matching image + assert: + that: + - info_2.images | length == 1 + - info_2.images[0].Index == "registry.access.redhat.com" + - info_2.images[0].Name == "registry.access.redhat.com/rhel7/rsyslog" + + - name: Search for specific image tags + containers.podman.podman_search: + term: registry.access.redhat.com/rhel7/rsyslog + list_tags: true + executable: "{{ test_executable | default('podman') }}" + register: info_3 + + - name: Check result for image tags + assert: + that: + - info_3.images | length == 1 + - info_3.images[0].Tags | length > 0 diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_secret/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_secret/tasks/main.yml index 66f827df5..c47ebb4bf 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_secret/tasks/main.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_secret/tasks/main.yml @@ -17,7 +17,10 @@ containers.podman.podman_secret: executable: "{{ test_executable | default('podman') }}" state: absent - name: mysecret + name: "{{ item }}" + loop: + - mysecret + - mysecret2 - name: Create secret containers.podman.podman_secret: @@ -283,7 +286,158 @@ containers.podman.podman_secret: executable: "{{ test_executable | default('podman') }}" state: absent - name: mysecret + name: "{{ item }}" + loop: + - mysecret + - mysecret2 + + - name: Create secret if not exists and skip existing + containers.podman.podman_secret: + executable: "{{ test_executable | default('podman') }}" + name: mysecret2 + data: secret content + state: present + skip_existing: true + register: secretskip1 + + - name: Create secret if not exists and skip existing - again + containers.podman.podman_secret: + executable: "{{ test_executable | default('podman') }}" + name: mysecret2 + data: secret content + state: present + skip_existing: true + register: secretskip2 + + - name: Check secret + containers.podman.podman_secret_info: + executable: "{{ test_executable | default('podman') }}" + name: mysecret2 + register: secret_info + + - name: Check outputs + assert: + that: + - secretskip1 is changed + - secretskip2 is not changed + - secret_info is success + - secret_info.secrets | length > 0 + + - name: Remove secret + containers.podman.podman_secret: + executable: "{{ test_executable | default('podman') }}" + state: absent + name: mysecret2 + + + - when: podman_version_gt470 + block: + + - name: Create a file with secret data + copy: + content: "secret content 1" + dest: ~/mysecret-1 + + - name: Create secret from file + containers.podman.podman_secret: + executable: "{{ test_executable | default('podman') }}" + name: mysecret2 + path: ~/mysecret-1 + state: present + register: secret1 + + - name: Create secret again + containers.podman.podman_secret: + executable: "{{ test_executable | default('podman') }}" + name: mysecret2 + path: ~/mysecret-1 + state: present + register: secret2 + + - name: Check outputs + assert: + that: + - secret1 is changed + - secret2 is not changed + + - name: Create another secret in other file + copy: + content: "secret content 2" + dest: ~/mysecret-2 + + - name: Create secret from other file + containers.podman.podman_secret: + executable: "{{ test_executable | default('podman') }}" + name: mysecret3 + path: ~/mysecret-2 + state: present + debug: true + register: secret3 + + - name: Check outputs + assert: + that: + - secret3 is changed + + - name: Create a secret from non existing file + containers.podman.podman_secret: + executable: "{{ test_executable | default('podman') }}" + name: mysecret4 + path: ~/mysecret-3 + state: present + debug: true + register: secret4 + ignore_errors: true + + - name: Check outputs + assert: + that: + - secret4 is failed + + - name: Create a secret from non-existing environment variable + containers.podman.podman_secret: + executable: "{{ test_executable | default('podman') }}" + name: mysecret5 + env: NON_EXISTING_ENV + state: present + register: secret5 + ignore_errors: true + + - name: Check outputs + assert: + that: + - secret5 is failed + - "'Environment variable NON_EXISTING_ENV is not set' in secret5.msg" + + - name: Create a secret from existing environment variable + containers.podman.podman_secret: + executable: "{{ test_executable | default('podman') }}" + name: mysecret5 + env: EXISTING_ENV + state: present + environment: + EXISTING_ENV: "secret env content" + register: secret6 + + - name: Show secret6 + containers.podman.podman_secret_info: + executable: "{{ test_executable | default('podman') }}" + name: mysecret5 + showsecret: true + register: secret6_info + + - name: Check outputs + assert: + that: + - secret6 is changed + - secret6_info is success + - secret6_info.secrets.0.SecretData == "secret env content" + + - name: Remove secret + containers.podman.podman_secret: + executable: "{{ test_executable | default('podman') }}" + state: absent + name: mysecret5 always: - name: Remove container that uses secret diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml index 9d43f3f1c..0b52fbfc8 100644 --- a/ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml +++ b/ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml @@ -161,6 +161,79 @@ - info10 is failed - delete.volume == {} + - name: Mount non existing volume + containers.podman.podman_volume: + executable: "{{ test_executable | default('podman') }}" + name: nonexistent + state: mounted + register: mount1 + + - name: Check results + assert: + that: + - mount1 is success + - "'mount_point' in mount1" + + - name: Create volume for mount + containers.podman.podman_volume: + executable: "{{ test_executable | default('podman') }}" + name: mountme + state: present + + - name: Mount existing volume + containers.podman.podman_volume: + executable: "{{ test_executable | default('podman') }}" + name: mountme + state: mounted + register: mount2 + + - name: Check results + assert: + that: + - mount2 is success + - "'mount_point' in mount2" + + - name: Unmount volume + containers.podman.podman_volume: + executable: "{{ test_executable | default('podman') }}" + name: mountme + state: unmounted + register: unmount + + - name: Check results + assert: + that: + - unmount is success + - "'mount_point' not in unmount" + + - name: Mount as root + become: true + containers.podman.podman_volume: + executable: "{{ test_executable | default('podman') }}" + name: rootmount + state: mounted + register: mount3 + + - name: Check results + assert: + that: + - mount3 is success + - "'mount_point' in mount3" + + - name: Unmount as root + become: true + containers.podman.podman_volume: + executable: "{{ test_executable | default('podman') }}" + name: rootmount + state: unmounted + register: unmount2 + + - name: Check results + assert: + that: + - unmount2 is success + - "'mount_point' not in unmount2" + - name: Create a Quadlet for volume with filename containers.podman.podman_volume: executable: "{{ test_executable | default('podman') }}" |