summaryrefslogtreecommitdiffstats
path: root/collections-debian-merged/ansible_collections/containers/podman/tests/integration
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:03:01 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:03:01 +0000
commita453ac31f3428614cceb99027f8efbdb9258a40b (patch)
treef61f87408f32a8511cbd91799f9cececb53e0374 /collections-debian-merged/ansible_collections/containers/podman/tests/integration
parentInitial commit. (diff)
downloadansible-a453ac31f3428614cceb99027f8efbdb9258a40b.tar.xz
ansible-a453ac31f3428614cceb99027f8efbdb9258a40b.zip
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collections-debian-merged/ansible_collections/containers/podman/tests/integration')
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/__init__.py0
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection/test_connection.yml43
-rwxr-xr-xcollections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_buildah/runme.sh24
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_buildah/test_connection.inventory12
-rwxr-xr-xcollections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_podman/runme.sh28
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_podman/test_connection.inventory15
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container/tasks/main.yml462
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/files/Dockerfile32
-rwxr-xr-xcollections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/files/start.sh5
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/build_test_container.yml30
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_all.yml224
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_labels.yml179
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_networks.yml40
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_pods.yml75
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_ports.yml240
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_stopsignal.yml204
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_users.yml169
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_volumes.yml234
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_workdir.yml204
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml46
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/root-podman-network.yml67
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/root-podman.yml153
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml103
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_info/tasks/main.yml88
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_containers/tasks/main.yml642
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_image/files/Containerfile3
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml190
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_image_info/tasks/main.yml50
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_login_info/tasks/main.yml62
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_logout/tasks/main.yml52
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml224
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_network_info/tasks/main.yml60
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml613
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/net-pod.yml48
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/network-tests.yml39
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/root-pod.yml120
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod_info/tasks/main.yml103
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml267
-rw-r--r--collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_volume_info/tasks/main.yml65
39 files changed, 5215 insertions, 0 deletions
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/__init__.py b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/__init__.py
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection/test_connection.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection/test_connection.yml
new file mode 100644
index 00000000..21699422
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection/test_connection.yml
@@ -0,0 +1,43 @@
+- hosts: "{{ target_hosts }}"
+ gather_facts: no
+ serial: 1
+ tasks:
+
+ ### raw with unicode arg and output
+
+ - name: raw with unicode arg and output
+ raw: echo 汉语
+ register: command
+ - name: check output of raw with unicode arg and output
+ assert:
+ that:
+ - "'汉语' in command.stdout"
+ - command is changed # as of 2.2, raw should default to changed: true for consistency w/ shell/command/script modules
+
+ ### copy local file with unicode filename and content
+
+ - name: create local file with unicode filename and content
+ local_action: lineinfile dest={{ local_tmp }}-汉语/汉语.txt create=true line=汉语
+ - name: remove remote file with unicode filename and content
+ action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语/汉语.txt state=absent"
+ - name: create remote directory with unicode name
+ action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=directory"
+ - name: copy local file with unicode filename and content
+ action: "{{ action_prefix }}copy src={{ local_tmp }}-汉语/汉语.txt dest={{ remote_tmp }}-汉语/汉语.txt"
+
+ ### fetch remote file with unicode filename and content
+
+ - name: remove local file with unicode filename and content
+ local_action: file path={{ local_tmp }}-汉语/汉语.txt state=absent
+ - name: fetch remote file with unicode filename and content
+ fetch: src={{ remote_tmp }}-汉语/汉语.txt dest={{ local_tmp }}-汉语/汉语.txt fail_on_missing=true validate_checksum=true flat=true
+
+ ### remove local and remote temp files
+
+ - name: remove local temp file
+ local_action: file path={{ local_tmp }}-汉语 state=absent
+ - name: remove remote temp file
+ action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=absent"
+
+ ### test wait_for_connection plugin
+ - wait_for_connection:
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_buildah/runme.sh b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_buildah/runme.sh
new file mode 100755
index 00000000..8da6526b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_buildah/runme.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+set -o pipefail
+set -eux
+
+function run_ansible {
+ ${SUDO:-} ${ANSIBLECMD:-ansible-playbook} ../connection/test_connection.yml -i "test_connection.inventory" \
+ -e target_hosts="buildah" \
+ -e action_prefix= \
+ -e local_tmp=/tmp/ansible-local \
+ -e remote_tmp=/tmp/ansible-remote \
+ "$@"
+
+}
+
+# First run as root
+run_ansible "$@"
+
+# Create a normal user
+${SUDO:-} ansible all -i "test_connection.inventory" -m "user" -a 'name="testuser"'
+
+# Second run as normal user
+ANSIBLE_VERBOSITY=4 ANSIBLE_REMOTE_USER="testuser" run_ansible "$@" | tee check_log
+${SUDO:-} grep -q "Using buildah connection from collection" check_log
+${SUDO:-} rm -f check_log
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_buildah/test_connection.inventory b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_buildah/test_connection.inventory
new file mode 100644
index 00000000..e6d090ee
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_buildah/test_connection.inventory
@@ -0,0 +1,12 @@
+[buildah]
+buildah-container ansible_ssh_pipelining=true
+[buildah:vars]
+# 1. install buildah
+# 2. create container:
+# $ sudo buildah from --name=buildah-container python:2
+# 3. run test:
+# $ ansible-test integration connection_buildah
+# 6. remove container
+# $ sudo buildah rm buildah-container
+ansible_host=buildah-container
+ansible_connection=containers.podman.buildah
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_podman/runme.sh b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_podman/runme.sh
new file mode 100755
index 00000000..eda49cf5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_podman/runme.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+
+set -o pipefail
+set -eux
+
+function run_ansible {
+ ${SUDO:-} ${ANSIBLECMD:-ansible-playbook} ../connection/test_connection.yml -i "test_connection.inventory" \
+ -e target_hosts="podman" \
+ -e action_prefix= \
+ -e local_tmp=/tmp/ansible-local \
+ -e remote_tmp=/tmp/ansible-remote \
+ "$@"
+
+}
+
+run_ansible "$@"
+LC_ALL=C LANG=C run_ansible "$@"
+ANSIBLE_VERBOSITY=4 ANSIBLE_REMOTE_TMP="/tmp" ANSIBLE_REMOTE_USER="1000" run_ansible "$@" | tee check_log
+${SUDO:-} grep -q "Using podman connection from collection" check_log
+${SUDO:-} rm -f check_log
+set +o pipefail
+ANSIBLE_PODMAN_EXECUTABLE=fakepodman run_ansible "$@" 2>&1 | grep "fakepodman command not found in PATH"
+set -o pipefail
+ANSIBLE_PODMAN_EXECUTABLE=fakepodman run_ansible "$@" && {
+ echo "Playbook with fakepodman should fail!"
+ exit 1
+}
+ANSIBLE_VERBOSITY=4 ANSIBLE_PODMAN_EXTRA_ARGS=" --log-level debug " run_ansible "$@" | grep "level=debug msg="
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_podman/test_connection.inventory b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_podman/test_connection.inventory
new file mode 100644
index 00000000..c64c399f
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/connection_podman/test_connection.inventory
@@ -0,0 +1,15 @@
+[podman]
+podman-container
+[podman:vars]
+# 1. install podman
+# 2. create container:
+# podman pull python:3-alpine
+# podman run -d --name podman-container python:3-alpine sleep 999999
+# 3. run test:
+# ./bin/ansible-test integration connection_podman
+# 6. remove container
+# podman stop podman-container
+# podman rm podman-container
+ansible_host=podman-container
+ansible_connection=containers.podman.podman
+ansible_python_interpreter=/usr/local/bin/python
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container/tasks/main.yml
new file mode 100644
index 00000000..edd721c7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container/tasks/main.yml
@@ -0,0 +1,462 @@
+- name: Test podman_container
+ block:
+ - name: Delete all container leftovers from tests
+ containers.podman.podman_container:
+ name: "{{ item }}"
+ state: absent
+ loop:
+ - "alpine:3.7"
+ - "container"
+ - "container2"
+
+ - name: Test no image with default action
+ containers.podman.podman_container:
+ name: container
+ ignore_errors: true
+ register: no_image
+
+ - name: Test no image with state 'started'
+ containers.podman.podman_container:
+ name: container
+ state: started
+ ignore_errors: true
+ register: no_image1
+
+ - name: Test no image with state 'present'
+ containers.podman.podman_container:
+ name: container
+ state: present
+ ignore_errors: true
+ register: no_image2
+
+ - name: Check no image
+ assert:
+ that:
+ - no_image is failed
+ - no_image1 is failed
+ - no_image2 is failed
+ - no_image.msg == "State 'started' required image to be configured!"
+ - no_image1.msg == "State 'started' required image to be configured!"
+ - no_image2.msg == "State 'present' required image to be configured!"
+ fail_msg: No image test failed!
+ success_msg: No image test passed!
+
+ - name: Ensure image doesn't exist
+ containers.podman.podman_image:
+ name: alpine:3.7
+ state: absent
+
+ - name: Check pulling image
+ containers.podman.podman_container:
+ name: container
+ image: alpine:3.7
+ state: present
+ command: sleep 1d
+ register: image
+
+ - name: Check using already pulled image
+ containers.podman.podman_container:
+ name: container2
+ image: alpine:3.7
+ state: present
+ command: sleep 1d
+ register: image2
+
+ - name: Check output is correct
+ assert:
+ that:
+ - image is changed
+ - image.container is defined
+ - image.container['State']['Running']
+ - "'pulled image alpine:3.7' in image.actions"
+ - "'started container' in image.actions"
+ - image2 is changed
+ - image2.container is defined
+ - image2.container['State']['Running']
+ - "'pulled image alpine:3.7' not in image2.actions"
+ - "'started container2' in image2.actions"
+ fail_msg: Pulling image test failed!
+ success_msg: Pulling image test passed!
+
+ - name: Check failed image pull
+ containers.podman.podman_container:
+ name: container
+ image: ineverneverneverexist
+ state: present
+ command: sleep 1d
+ register: imagefail
+ ignore_errors: true
+
+ - name: Check output is correct
+ assert:
+ that:
+ - imagefail is failed
+ - imagefail.msg == "Can't pull image ineverneverneverexist"
+
+
+ - name: Force container recreate
+ containers.podman.podman_container:
+ name: container
+ image: alpine
+ state: present
+ command: sleep 1d
+ recreate: true
+ register: recreated
+
+ - name: Check output is correct
+ assert:
+ that:
+ - recreated is changed
+ - recreated.container is defined
+ - recreated.container['State']['Running']
+ - "'recreated container' in recreated.actions"
+ fail_msg: Force recreate test failed!
+ success_msg: Force recreate test passed!
+
+ - name: Stop container
+ containers.podman.podman_container:
+ name: container
+ state: stopped
+ register: stopped
+
+ - name: Stop the same container again (idempotency)
+ containers.podman.podman_container:
+ name: container
+ state: stopped
+ register: stopped_again
+
+ - name: Check output is correct
+ assert:
+ that:
+ - stopped is changed
+ - stopped.container is defined
+ - not stopped.container['State']['Running']
+ - "'stopped container' in stopped.actions"
+ - stopped_again is not changed
+ - stopped_again.container is defined
+ - not stopped_again.container['State']['Running']
+ - stopped_again.actions == []
+ fail_msg: Stopping container test failed!
+ success_msg: Stopping container test passed!
+
+ - name: Delete stopped container
+ containers.podman.podman_container:
+ name: container
+ state: absent
+ register: deleted
+
+ - name: Delete again container (idempotency)
+ containers.podman.podman_container:
+ name: container
+ state: absent
+ register: deleted_again
+
+ - name: Check output is correct
+ assert:
+ that:
+ - deleted is changed
+ - deleted.container is defined
+ - deleted.container == {}
+ - "'deleted container' in deleted.actions"
+ - deleted_again is not changed
+ - deleted_again.container is defined
+ - deleted_again.container == {}
+ - deleted_again.actions == []
+ fail_msg: Deleting stopped container test failed!
+ success_msg: Deleting stopped container test passed!
+
+ - name: Create container, but don't run
+ containers.podman.podman_container:
+ name: container
+ image: alpine:3.7
+ state: stopped
+ command: sleep 1d
+ register: created
+
+ - name: Check output is correct
+ assert:
+ that:
+ - created is changed
+ - created.container is defined
+ - created.container != {}
+ - not created.container['State']['Running']
+ - "'created container' in created.actions"
+ fail_msg: "Creating stopped container test failed!"
+ success_msg: "Creating stopped container test passed!"
+
+ - name: Delete created container
+ containers.podman.podman_container:
+ name: container
+ state: absent
+
+ - name: Start container that was deleted
+ containers.podman.podman_container:
+ name: container
+ image: alpine:3.7
+ state: started
+ command: sleep 1d
+ register: started
+
+ - name: Check output is correct
+ assert:
+ that:
+ - started is changed
+ - started.container is defined
+ - started.container['State']['Running']
+ - "'pulled image alpine:3.7' not in started.actions"
+
+ - name: Delete started container
+ containers.podman.podman_container:
+ name: container
+ state: absent
+ register: deleted
+
+ - name: Delete again container (idempotency)
+ containers.podman.podman_container:
+ name: container
+ state: absent
+ register: deleted_again
+
+ - name: Check output is correct
+ assert:
+ that:
+ - deleted is changed
+ - deleted.container is defined
+ - deleted.container == {}
+ - "'deleted container' in deleted.actions"
+ - deleted_again is not changed
+ - deleted_again.container is defined
+ - deleted_again.container == {}
+ - deleted_again.actions == []
+ fail_msg: Deleting started container test failed!
+ success_msg: Deleting started container test passed!
+
+ - name: Recreate container with parameters
+ containers.podman.podman_container:
+ name: container
+ image: docker.io/alpine:3.7
+ state: started
+ command: sleep 1d
+ recreate: true
+ etc_hosts:
+ host1: 127.0.0.1
+ host2: 127.0.0.1
+ annotation:
+ this: "annotation_value"
+ dns:
+ - 1.1.1.1
+ - 8.8.4.4
+ dns_search: example.com
+ cap_add:
+ - SYS_TIME
+ - NET_ADMIN
+ publish:
+ - "9000:80"
+ - "9001:8000"
+ workdir: "/bin"
+ env:
+ FOO: bar=1
+ BAR: foo
+ TEST: 1
+ BOOL: false
+ label:
+ somelabel: labelvalue
+ otheralbe: othervalue
+ volumes:
+ - /tmp:/data
+ register: test
+
+ - name: Check output is correct
+ assert:
+ that:
+ - test is changed
+ - test.container is defined
+ - test.container != {}
+ - test.container['State']['Running']
+ # test capabilities
+ - "'CAP_SYS_TIME' in test.container['BoundingCaps']"
+ - "'CAP_NET_ADMIN' in test.container['BoundingCaps']"
+ # test annotations
+ - test.container['Config']['Annotations']['this'] is defined
+ - test.container['Config']['Annotations']['this'] == "annotation_value"
+ # test DNS
+ - >-
+ (test.container['HostConfig']['Dns'] is defined and
+ test.container['HostConfig']['Dns'] == ['1.1.1.1', '8.8.4.4']) or
+ (test.container['HostConfig']['DNS'] is defined and
+ test.container['HostConfig']['DNS'] == ['1.1.1.1', '8.8.4.4'])
+ # test ports
+ - test.container['NetworkSettings']['Ports']|length == 2
+ # test working dir
+ - test.container['Config']['WorkingDir'] == "/bin"
+ # test dns search
+ - >-
+ (test.container['HostConfig']['DnsSearch'] is defined and
+ test.container['HostConfig']['DnsSearch'] == ['example.com']) or
+ (test.container['HostConfig']['DNSSearch'] is defined and
+ test.container['HostConfig']['DNSSearch'] == ['example.com'])
+ # test environment variables
+ - "'FOO=bar=1' in test.container['Config']['Env']"
+ - "'BAR=foo' in test.container['Config']['Env']"
+ - "'TEST=1' in test.container['Config']['Env']"
+ - "'BOOL=False' in test.container['Config']['Env']"
+ # test labels
+ - test.container['Config']['Labels'] | length == 2
+ - test.container['Config']['Labels']['somelabel'] == "labelvalue"
+ - test.container['Config']['Labels']['otheralbe'] == "othervalue"
+ # test mounts
+ - >-
+ (test.container['Mounts'][0]['Destination'] is defined and
+ '/data' in test.container['Mounts'] | map(attribute='Destination') | list) or
+ (test.container['Mounts'][0]['destination'] is defined and
+ '/data' in test.container['Mounts'] | map(attribute='destination') | list)
+ - >-
+ (test.container['Mounts'][0]['Source'] is defined and
+ '/tmp' in test.container['Mounts'] | map(attribute='Source') | list) or
+ (test.container['Mounts'][0]['source'] is defined and
+ '/tmp' in test.container['Mounts'] | map(attribute='source') | list)
+ fail_msg: Parameters container test failed!
+ success_msg: Parameters container test passed!
+
+ - name: Check basic idempotency of running container
+ containers.podman.podman_container:
+ name: testidem
+ image: docker.io/alpine
+ state: present
+ command: sleep 20m
+
+ - name: Check basic idempotency of running container - run it again
+ containers.podman.podman_container:
+ name: testidem
+ image: alpine:latest
+ state: present
+ command: sleep 20m
+ register: idem
+
+ - name: Check that nothing was changed
+ assert:
+ that:
+ - not idem.changed
+
+ - name: Check force restart option - run again and force restart
+ containers.podman.podman_container:
+ name: testidem
+ image: alpine:latest
+ state: present
+ command: sleep 20m
+ force_restart: true
+ register: idem_r
+
+ - name: Check that task was changed
+ assert:
+ that:
+ - idem_r is changed
+
+ - name: Check removing force_restart option
+ containers.podman.podman_container:
+ name: testidem
+ image: alpine:latest
+ state: present
+ command: sleep 20m
+ register: idem_r1
+
+ - name: Check that task was not changed
+ assert:
+ that:
+ - idem_r1 is not changed
+
+ - name: Run changed container (with tty enabled)
+ containers.podman.podman_container:
+ name: testidem
+ image: alpine
+ state: present
+ command: sleep 20m
+ tty: true
+ register: idem1
+
+ - name: Check that container is recreated when changed
+ assert:
+ that:
+ - idem1 is changed
+
+ - name: Run changed container without specifying an option, use defaults
+ containers.podman.podman_container:
+ name: testidem
+ image: alpine
+ state: present
+ command: sleep 20m
+ register: idem2
+
+ - name: Check that container is recreated when changed to default value
+ assert:
+ that:
+ - idem2 is changed
+
+ - name: Remove container
+ containers.podman.podman_container:
+ name: testidem
+ state: absent
+ register: remove
+
+ - name: Check podman_actions
+ assert:
+ that:
+ - "'podman rm -f testidem' in remove.podman_actions"
+
+ # - name: Create a pod
+ # shell: podman pod create --name testidempod
+
+ - name: Check basic idempotency of pod container
+ containers.podman.podman_container:
+ name: testidem-pod
+ image: docker.io/alpine
+ state: present
+ command: sleep 20m
+ pod: "new:testidempod"
+
+ - name: Check basic idempotency of pod container - run it again
+ containers.podman.podman_container:
+ name: testidem-pod
+ image: alpine:latest
+ state: present
+ command: sleep 20m
+ pod: testidempod
+ register: idem3
+
+ - name: Check that nothing was changed in pod containers
+ assert:
+ that:
+ - not idem3.changed
+
+ - name: Run changed pod container (with tty enabled)
+ containers.podman.podman_container:
+ name: testidem-pod
+ image: alpine
+ state: present
+ command: sleep 20m
+ tty: true
+ pod: testidempod
+ register: idem4
+
+ - name: Check that container is recreated when changed
+ assert:
+ that:
+ - idem4 is changed
+
+ - name: Remove container
+ containers.podman.podman_container:
+ name: testidem-pod
+ state: absent
+
+ always:
+ - name: Delete all container leftovers from tests
+ containers.podman.podman_container:
+ name: "{{ item }}"
+ state: absent
+ loop:
+ - "alpine:3.7"
+ - "container"
+ - "container2"
+
+ - name: Remove pod
+ shell: podman pod rm -f testidempod
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/files/Dockerfile b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/files/Dockerfile
new file mode 100644
index 00000000..8d32e4a3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/files/Dockerfile
@@ -0,0 +1,32 @@
+FROM alpine
+
+LABEL "key"="amazing value"
+LABEL nobody=cares
+
+ARG build_arg
+
+ENV password root
+ENV username root
+
+WORKDIR /work
+
+RUN adduser -D user && \
+ adduser -D user2
+
+COPY start.sh /start
+
+RUN chmod a+rwx /start
+
+EXPOSE 80
+EXPOSE 8080/tcp
+VOLUME ["/data", "/data2"]
+USER user
+STOPSIGNAL SIGKILL
+
+# problem with OS w/o systemd
+# HEALTHCHECK --interval=5m --timeout=3s \
+# CMD date
+
+CMD ["1d"]
+ENTRYPOINT ["/start"]
+
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/files/start.sh b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/files/start.sh
new file mode 100755
index 00000000..1217239e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/files/start.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+s=${1:-"3h"}
+sleep "$s"
+
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/build_test_container.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/build_test_container.yml
new file mode 100644
index 00000000..a9ecb039
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/build_test_container.yml
@@ -0,0 +1,30 @@
+---
+- name: Create directory for user build images
+ file:
+ path: /tmp/usr_img
+ state: directory
+
+- name: Copy files to container build directory
+ copy:
+ src: "{{ item }}"
+ dest: "/tmp/usr_img/{{ item }}"
+ mode: 777
+ loop:
+ - Dockerfile
+ - start.sh
+
+- name: Build test docker image for regular user
+ containers.podman.podman_image:
+ name: "{{ idem_image }}"
+ path: /tmp/usr_img
+ build:
+ format: docker
+ extra_args: --cgroup-manager=cgroupfs
+
+- name: Build test docker image for root user
+ containers.podman.podman_image:
+ name: "{{ idem_image }}"
+ path: /tmp/usr_img
+ build:
+ format: docker
+ become: true
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_all.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_all.yml
new file mode 100644
index 00000000..15a4d658
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_all.yml
@@ -0,0 +1,224 @@
+# Other settings
+- name: Remove leftovers from other tests
+ containers.podman.podman_container:
+ name: idempotency
+ state: absent
+
+- name: Run container
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+
+- name: Run container again
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test1
+
+- name: Check info when running container again
+ assert:
+ that: test1 is not changed
+
+- name: Run container with environment vars
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ env:
+ mykey: "amazing value"
+ ENV1: "one=two=three"
+ command: 1h
+ register: test2
+
+- name: Check info with environment vars
+ assert:
+ that: test2 is changed
+
+- name: Run container with environment vars again
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ env:
+ mykey: "amazing value"
+ ENV1: "one=two=three"
+ command: 1h
+ register: test3
+
+- name: Check info with environment vars again
+ assert:
+ that: test3 is not changed
+
+- name: Run container with changed environment vars
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ env:
+ mykey: "amazing value1"
+ ENV1: "one=two=three"
+ command: 1h
+ register: test4
+
+- name: Check info with changed environment vars
+ assert:
+ that: test4 is changed
+
+- name: Run container with log level
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ log_level: debug
+ command: 1h
+ register: test5
+
+- name: Check info with log level
+ assert:
+ that: test5 is changed
+
+- name: Run container with log level again
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ log_level: debug
+ command: 1h
+ register: test6
+
+- name: Check info with log level again
+ assert:
+ that: test6 is not changed
+
+- name: Run container with changed log level
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ log_level: error
+ command: 1h
+ register: test7
+
+- name: Check info with changed log level
+ assert:
+ that: test7 is changed
+
+- name: Run container with default log level
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test8
+
+- name: Check info with default log level
+ assert:
+ that: test8 is not changed
+
+- name: Run container with log opt tag
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ log_opt:
+ tag: nonotag
+ log_driver: journald
+ command: 1h
+ register: test9
+
+- name: Check info with log opt tag
+ assert:
+ that: test9 is changed
+
+- name: Run container with log opt tag - again
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ log_opt:
+ tag: nonotag
+ log_driver: journald
+ command: 1h
+ register: test10
+
+- name: Check info with log opt tag - again
+ assert:
+ that: test10 is not changed
+
+- name: Run container with default log opt tag
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ log_driver: journald
+ register: test11
+
+- name: Check info with default log opt tag
+ assert:
+ that: test11 is changed
+
+- name: Run container with log opt path
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ log_opt:
+ path: /tmp/container.log
+ log_driver: journald
+ command: 1h
+ register: test12
+
+- name: Check info with log opt path
+ assert:
+ that: test12 is changed
+
+- name: Run container with changed log opt path
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ log_opt:
+ path: /tmp/container2.log
+ log_driver: journald
+ command: 1h
+ register: test13
+
+- name: Check info with changed log opt path
+ assert:
+ that: test13 is changed
+
+- name: Run container with default log opt path
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ log_driver: journald
+ 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
+
+- name: Run container with all log-opts
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ log_driver: journald
+ log_opt:
+ path: /tmp/container3.log
+ max_size: 100mb
+ tag: sometag
+ command: 1h
+
+- name: Remove test container
+ containers.podman.podman_container:
+ name: idempotency
+ state: absent
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_labels.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_labels.yml
new file mode 100644
index 00000000..b7627fc7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_labels.yml
@@ -0,0 +1,179 @@
+# Labels
+- containers.podman.podman_container:
+ name: idempotency
+ state: absent
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test1
+
+- name: check test1
+ assert:
+ that: test1 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ label:
+ key: "amazing value"
+ nobody: "cares"
+ command: 1h
+ register: test2
+
+- name: check test2
+ assert:
+ that: test2 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test3
+
+- name: check test3
+ assert:
+ that: test3 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ label:
+ haha: kukuku
+ llala: wiwiwiw
+ command: 1h
+ register: test4
+
+- name: check test4
+ assert:
+ that: test4 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ label:
+ haha: kukuku
+ llala: wiwiwiw
+ command: 1h
+ register: test5
+
+- name: check test5
+ assert:
+ that: test5 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test6
+
+- name: check test6
+ assert:
+ that: test6 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ label:
+ test: notest
+ command: 1h
+ register: test7
+
+- name: check test7
+ assert:
+ that: test7 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ label:
+ key: "amazing value"
+ nobody: "cares"
+ command: 1h
+ register: test8
+
+- name: check test8
+ assert:
+ that: test8 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test9
+
+- name: check test9
+ assert:
+ that: test9 is not changed
+
+- containers.podman.podman_container:
+ name: idempotency1
+ state: absent
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test10
+
+- name: check test10
+ assert:
+ that: test10 is not changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ label:
+ razraz: dva
+ command: sleep 1h
+ register: test11
+
+- name: check test11
+ assert:
+ that: test11 is changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test12
+
+- name: check test12
+ assert:
+ that: test12 is changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test13
+
+- name: check test13
+ assert:
+ that: test13 is not changed
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_networks.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_networks.yml
new file mode 100644
index 00000000..5a21aac4
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_networks.yml
@@ -0,0 +1,40 @@
+- name: Remove container netcontainer
+ containers.podman.podman_container:
+ name: netcontainer
+ state: absent
+
+- name: Run container with {{ item.first_net }}
+ containers.podman.podman_container:
+ name: netcontainer
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network: "{{ item.first_net }}"
+
+- name: Run container again with {{ item.first_net }}
+ containers.podman.podman_container:
+ name: netcontainer
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network: "{{ item.first_net }}"
+ register: info
+
+- name: Check info for 2 runs of {{ item.first_net }}
+ assert:
+ that:
+ - info is not changed
+
+- name: Run changed container with {{ item.next_net }}
+ containers.podman.podman_container:
+ name: netcontainer
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network: "{{ item.next_net }}"
+ register: info1
+
+- name: Check info
+ assert:
+ that:
+ - info1 is changed
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_pods.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_pods.yml
new file mode 100644
index 00000000..aae118e1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_pods.yml
@@ -0,0 +1,75 @@
+- name: Remove testing pod
+ containers.podman.podman_pod:
+ name: testpod
+ state: absent
+
+- name: Remove test container
+ containers.podman.podman_container:
+ name: testpod_container1
+ state: absent
+
+- name: Create pod
+ containers.podman.podman_pod:
+ name: testpod
+ publish:
+ - "11111:11111"
+
+- name: Start test container
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: testpod_container1
+ pod: testpod
+ state: started
+ label:
+ key: value
+ env:
+ test: test2
+ volumes:
+ - /tmp:/data
+
+- name: Start test container again
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: testpod_container1
+ pod: testpod
+ state: started
+ label:
+ key: value
+ env:
+ test: test2
+ volumes:
+ - /tmp:/data
+ register: info
+
+- name: Check starting container
+ assert:
+ that: info is not changed
+
+- name: Start test container changed
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: testpod_container1
+ pod: testpod
+ state: started
+ register: info1
+
+- name: Check starting container changed
+ assert:
+ that: info1 is changed
+
+- name: Start test container again
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: testpod_container1
+ pod: testpod
+ state: started
+ register: info2
+
+- name: Check starting container again
+ assert:
+ that: info2 is not changed
+
+- name: Remove testing pod
+ containers.podman.podman_pod:
+ name: testpod
+ state: absent
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_ports.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_ports.yml
new file mode 100644
index 00000000..9e029b80
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_ports.yml
@@ -0,0 +1,240 @@
+# Ports
+- containers.podman.podman_container:
+ name: idempotency
+ state: absent
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test1
+
+- name: check test1
+ assert:
+ that: test1 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ ports:
+ - "4444:4444/tcp"
+ - "1212:5555"
+ - "8888:19191/udp"
+ - "1900:1900/udp"
+ - "127.0.0.1:7671:7676/udp"
+ - "127.0.0.1:12122:8876/udp"
+ - "127.0.0.1:13122:8871/tcp"
+ - "127.0.0.1:43423:8872"
+ register: test2
+
+- name: check test2
+ assert:
+ that: test2 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ ports:
+ - "4444:4444/tcp"
+ - "1212:5555"
+ - "8888:19191/udp"
+ - "1900:1900/udp"
+ - "127.0.0.1:7671:7676/udp"
+ - "127.0.0.1:12122:8876/udp"
+ - "127.0.0.1:13122:8871/tcp"
+ - "127.0.0.1:43423:8872"
+ register: test3
+
+- name: check test3
+ assert:
+ that: test3 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ publish_all: true
+ command: 1h
+ register: test4
+
+- name: check test4
+ assert:
+ that: test4 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ publish_all: true
+ command: 1h
+ register: test5
+
+- name: check test5
+ assert:
+ that: test5 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test6
+
+- name: check test6
+ assert:
+ that: test6 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ ports:
+ - 10000:8080
+ command: 1h
+ register: test7
+
+- name: check test7
+ assert:
+ that: test7 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ ports:
+ - 10001:8080
+ command: 1h
+ register: test8
+
+- name: check test8
+ assert:
+ that: test8 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ ports:
+ - 10001:8080/tcp
+ command: 1h
+ register: test9
+
+- name: check test9
+ assert:
+ that: test9 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ ports:
+ - 10001:8080/tcp
+ publish_all: false
+ command: 1h
+ register: test9a
+
+- name: check test9a
+ assert:
+ that: test9a is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test9b
+
+- name: check test9b
+ assert:
+ that: test9b is changed
+
+- containers.podman.podman_container:
+ name: idempotency1
+ state: absent
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test10
+
+- name: check test10
+ assert:
+ that: test10 is not changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ publish_all: false
+ command: sleep 1h
+ register: test11
+
+- name: check test11
+ assert:
+ that: test11 is not changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ publish_all: true
+ command: sleep 1h
+ register: test11a
+
+- name: check test11a
+ assert:
+ that: test11a is not changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ ports:
+ - 10000:8080
+ command: sleep 1h
+ register: test12
+
+- name: check test12
+ assert:
+ that: test12 is changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test13
+
+- name: check test13
+ assert:
+ that: test13 is changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test14
+
+- name: check test14
+ assert:
+ that: test14 is not changed
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_stopsignal.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_stopsignal.yml
new file mode 100644
index 00000000..c4b2ded5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_stopsignal.yml
@@ -0,0 +1,204 @@
+# Stop signal
+- containers.podman.podman_container:
+ name: idempotency
+ state: absent
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test1
+
+- name: check test1
+ assert:
+ that: test1 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ stop_signal: 9
+ command: 1h
+ register: test2
+
+- name: check test2
+ assert:
+ that: test2 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test3
+
+- name: check test3
+ assert:
+ that: test3 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ stop_signal: 10
+ command: 1h
+ register: test4
+
+- name: check test4
+ assert:
+ that: test4 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ stop_signal: 10
+ command: 1h
+ register: test5
+
+- name: check test5
+ assert:
+ that: test5 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test6
+
+- name: check test6
+ assert:
+ that: test6 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ stop_signal: 15
+ command: 1h
+ register: test7
+
+- name: check test7
+ assert:
+ that: test7 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ stop_signal: 9
+ command: 1h
+ register: test8
+
+- name: check test8
+ assert:
+ that: test8 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test9
+
+- name: check test9
+ assert:
+ that: test9 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ stop_signal: 15
+ command: 1h
+ register: test9a
+
+- name: check test9a
+ assert:
+ that: test9a is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test9b
+
+- name: check test9b
+ assert:
+ that: test9b is changed
+
+- containers.podman.podman_container:
+ name: idempotency1
+ state: absent
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test10
+
+- name: check test10
+ assert:
+ that: test10 is not changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ stop_signal: 15
+ command: sleep 1h
+ register: test11
+
+- name: check test11
+ assert:
+ that: test11 is not changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ stop_signal: 10
+ command: sleep 1h
+ register: test12
+
+- name: check test12
+ assert:
+ that: test12 is changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test13
+
+- name: check test13
+ assert:
+ that: test13 is changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test14
+
+- name: check test14
+ assert:
+ that: test14 is not changed
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_users.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_users.yml
new file mode 100644
index 00000000..ad1f103a
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_users.yml
@@ -0,0 +1,169 @@
+# Users
+- containers.podman.podman_container:
+ name: idempotency
+ state: absent
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test1
+
+- name: check test1
+ assert:
+ that: test1 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ user: user
+ command: 1h
+ register: test2
+
+- name: check test2
+ assert:
+ that: test2 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test3
+
+- name: check test3
+ assert:
+ that: test3 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ user: user2
+ command: 1h
+ register: test4
+
+- name: check test4
+ assert:
+ that: test4 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ user: user2
+ command: 1h
+ register: test5
+
+- name: check test5
+ assert:
+ that: test5 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test6
+
+- name: check test6
+ assert:
+ that: test6 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ user: user2
+ command: 1h
+ register: test7
+
+- name: check test7
+ assert:
+ that: test7 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ user: user
+ command: 1h
+ register: test8
+
+- name: check test8
+ assert:
+ that: test8 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test9
+
+- name: check test9
+ assert:
+ that: test9 is not changed
+
+- containers.podman.podman_container:
+ name: idempotency1
+ state: absent
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test10
+
+- name: check test10
+ assert:
+ that: test10 is not changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ user: nobody
+ command: sleep 1h
+ register: test11
+
+- name: check test11
+ assert:
+ that: test11 is changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test12
+
+- name: check test12
+ assert:
+ that: test12 is changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test13
+
+- name: check test13
+ assert:
+ that: test13 is not changed
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_volumes.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_volumes.yml
new file mode 100644
index 00000000..475e4494
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_volumes.yml
@@ -0,0 +1,234 @@
+# Volumes
+- containers.podman.podman_container:
+ name: idempotency
+ state: absent
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test1
+
+- name: check test1
+ assert:
+ that: test1 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test2
+
+- name: check test2
+ assert:
+ that: test2 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test3
+
+- name: check test3
+ assert:
+ that: test3 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ volumes:
+ - /opt:/somedir
+ command: 1h
+ register: test4
+
+- name: check test4
+ assert:
+ that: test4 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ volumes:
+ - /opt/://somedir
+ command: 1h
+ register: test5
+
+- name: check test5
+ assert:
+ that: test5 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test6
+
+- name: check test6
+ assert:
+ that: test6 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ volumes:
+ - /opt:/somedir
+ - /data
+ command: 1h
+ register: test7
+
+- name: check test7
+ assert:
+ that: test7 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ volumes:
+ - /data
+ command: 1h
+ register: test8
+
+- name: check test8
+ assert:
+ that: test8 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test9
+
+- name: check test9
+ assert:
+ that: test9 is not changed
+
+- name: Create volumes
+ shell: |
+ podman volume inspect local_volume1 || podman volume create local_volume1
+ podman volume inspect local_volume2 || podman volume create local_volume2
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ volumes:
+ - "/opt:/anotherdir"
+ - "local_volume1:/data"
+ register: test10
+
+- name: check test10
+ assert:
+ that: test10 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ volumes:
+ - "/opt//:/anotherdir"
+ - "local_volume1:/data/"
+ register: test11
+
+- name: check test11
+ assert:
+ that: test11 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ volumes:
+ - "/opt:/anotherdir"
+ - "local_volume2:/data"
+ register: test12
+
+- name: check test12
+ assert:
+ that: test12 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ volumes:
+ - "/opt:/anotherdir"
+ register: test13
+
+- name: check test13
+ assert:
+ that: test13 is not changed
+
+- containers.podman.podman_container:
+ name: idempotency1
+ state: absent
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test14
+
+- name: check test14
+ assert:
+ that: test14 is not changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ volumes:
+ - /opt:/data
+ command: sleep 1h
+ register: test15
+
+- name: check test15
+ assert:
+ that: test15 is changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test16
+
+- name: check test16
+ assert:
+ that: test16 is changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test17
+
+- name: check test17
+ assert:
+ that: test17 is not changed
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_workdir.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_workdir.yml
new file mode 100644
index 00000000..b6d0fa35
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/idem_workdir.yml
@@ -0,0 +1,204 @@
+# Workdir
+- containers.podman.podman_container:
+ name: idempotency
+ state: absent
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test1
+
+- name: check test1
+ assert:
+ that: test1 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ workdir: /work
+ command: 1h
+ register: test2
+
+- name: check test2
+ assert:
+ that: test2 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test3
+
+- name: check test3
+ assert:
+ that: test3 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ workdir: /app
+ command: 1h
+ register: test4
+
+- name: check test4
+ assert:
+ that: test4 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ workdir: /app
+ command: 1h
+ register: test5
+
+- name: check test5
+ assert:
+ that: test5 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test6
+
+- name: check test6
+ assert:
+ that: test6 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ workdir: /app
+ command: 1h
+ register: test7
+
+- name: check test7
+ assert:
+ that: test7 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ workdir: /work
+ command: 1h
+ register: test8
+
+- name: check test8
+ assert:
+ that: test8 is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test9
+
+- name: check test9
+ assert:
+ that: test9 is not changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ workdir: /
+ command: 1h
+ register: test9a
+
+- name: check test9a
+ assert:
+ that: test9a is changed
+
+- containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: idempotency
+ state: present
+ command: 1h
+ register: test9b
+
+- name: check test9b
+ assert:
+ that: test9b is changed
+
+- containers.podman.podman_container:
+ name: idempotency1
+ state: absent
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test10
+
+- name: check test10
+ assert:
+ that: test10 is not changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ workdir: /
+ command: sleep 1h
+ register: test11
+
+- name: check test11
+ assert:
+ that: test11 is not changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ workdir: /app
+ command: sleep 1h
+ register: test12
+
+- name: check test12
+ assert:
+ that: test12 is changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test13
+
+- name: check test13
+ assert:
+ that: test13 is changed
+
+- containers.podman.podman_container:
+ image: alpine
+ name: idempotency1
+ state: present
+ command: sleep 1h
+ register: test14
+
+- name: check test14
+ assert:
+ that: test14 is not changed
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml
new file mode 100644
index 00000000..b207f73b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml
@@ -0,0 +1,46 @@
+---
+- name: Prepare a container
+ include_tasks: build_test_container.yml
+
+- name: Test idempotency of users
+ include_tasks: idem_users.yml
+
+- name: Test idempotency of workdir
+ include_tasks: idem_workdir.yml
+
+- name: Test idempotency of labels
+ include_tasks: idem_labels.yml
+
+- name: Test idempotency of stop signal
+ include_tasks: idem_stopsignal.yml
+
+- name: Test idempotency of ports
+ include_tasks: idem_ports.yml
+
+- name: Test idempotency of volumes
+ include_tasks: idem_volumes.yml
+
+- name: Test idempotency of containers in pods
+ include_tasks: idem_pods.yml
+
+- name: Test idempotency of other settings
+ include_tasks: idem_all.yml
+
+- name: Test idempotency for root containers
+ include_tasks: root-podman.yml
+ vars:
+ ansible_python_interpreter: "/usr/bin/python"
+ args:
+ apply:
+ become: true
+
+- name: Test idempotency for root network containers
+ include_tasks: root-podman-network.yml
+ vars:
+ ansible_python_interpreter: "/usr/bin/python"
+ args:
+ apply:
+ become: true
+
+- name: Test idempotency for root network containers
+ include_tasks: rootless-podman-network.yml
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/root-podman-network.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/root-podman-network.yml
new file mode 100644
index 00000000..bdcbd157
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/root-podman-network.yml
@@ -0,0 +1,67 @@
+- name: Test podman rootful container with networks
+ block:
+
+ - name: Remove container
+ containers.podman.podman_container:
+ name: netcontainer
+ state: absent
+
+ - name: Create network testnet
+ command: podman network create testnet --subnet 10.92.92.0/24
+
+ - name: Create network anothernet
+ command: podman network create anothernet --subnet 10.72.72.0/24
+
+ - name: List current networks
+ command: podman network ls
+
+ - name: Set test data
+ set_fact:
+ testdata:
+ - first_net: host
+ next_net: bridge
+ - first_net: bridge
+ next_net: host
+ - first_net: none
+ next_net: host
+ - first_net: host
+ next_net: none
+ - first_net: anothernet
+ next_net: testnet
+ - first_net: testnet
+ next_net:
+ - testnet
+ - anothernet
+ - first_net:
+ - testnet
+ - anothernet
+ next_net: anothernet
+ - first_net:
+ - testnet
+ - anothernet
+ next_net: bridge
+ - first_net:
+ - testnet
+ - anothernet
+ next_net: host
+ - first_net: host
+ next_net: anothernet
+ - first_net: bridge
+ next_net:
+ - anothernet
+ - testnet
+
+ - include_tasks: idem_networks.yml
+ loop: "{{ testdata }}"
+
+ always:
+
+ - name: Delete all pods leftovers from tests
+ containers.podman.podman_container:
+ name: netcontainer
+ state: absent
+
+ - name: Delete all network leftovers from tests
+ shell: |
+ podman network rm -f anothernet
+ podman network rm -f testnet
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/root-podman.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/root-podman.yml
new file mode 100644
index 00000000..eccc4e89
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/root-podman.yml
@@ -0,0 +1,153 @@
+---
+# Ulimits testing
+- name: Make sure container doesn't exist
+ containers.podman.podman_container:
+ name: root-idempotency
+ state: absent
+
+- name: Run container as is
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: root-idempotency
+ state: present
+ command: 1h
+
+- name: Run container as is again
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: root-idempotency
+ state: present
+ command: 1h
+ register: info_a
+
+- name: Check that it is not recreated
+ assert:
+ that:
+ - info_a is not changed
+
+- name: Run containers with ulimits
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: root-idempotency
+ state: present
+ command: 1h
+ ulimit:
+ - 'nofile=55535:55535'
+ - 'memlock=-1:-1'
+ register: info
+
+- name: Check that it is recreated
+ assert:
+ that:
+ - info is changed
+
+- name: Run containers with ulimits - idempotency
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: root-idempotency
+ state: present
+ command: 1h
+ ulimit:
+ - 'nofile=55535:55535'
+ - 'memlock=-1:-1'
+ register: info1
+
+- name: Check that it is recreated
+ assert:
+ that:
+ - info1 is not changed
+
+- name: Run containers with changed ulimits
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: root-idempotency
+ state: present
+ command: 1h
+ ulimit:
+ - 'nofile=55535:65535'
+ - 'memlock=-1:-1'
+ register: info2
+
+- name: Check that it is recreated
+ assert:
+ that:
+ - info2 is changed
+
+- name: Run containers with changed ulimits - idempotency
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: root-idempotency
+ state: present
+ command: 1h
+ ulimit:
+ - 'nofile=55535:65535'
+ - 'memlock=-1:-1'
+ register: info3
+
+- name: Check that it is recreated
+ assert:
+ that:
+ - info3 is not changed
+
+- name: Run default container
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: root-idempotency
+ state: present
+ command: 1h
+
+- name: Run containers with MAC address
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: root-idempotency
+ state: present
+ command: 1h
+ mac_address: 44:55:66:77:88:99
+ register: info4
+
+- name: Check that it is not recreated
+ assert:
+ that:
+ - info4 is changed
+ - info4.container['NetworkSettings']['MacAddress'] == '44:55:66:77:88:99'
+
+- name: Run containers with MAC address again - idempotency
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: root-idempotency
+ state: present
+ command: 1h
+ mac_address: 44:55:66:77:88:99
+ register: info5
+
+- name: Check that it is not recreated
+ assert:
+ that:
+ - info5 is not changed
+
+- name: Run containers with MAC address changed
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: root-idempotency
+ state: present
+ command: 1h
+ mac_address: 44:55:66:77:88:33
+ register: info6
+
+- name: Check that it is recreated
+ assert:
+ that:
+ - info6 is changed
+
+- name: Run again default container
+ containers.podman.podman_container:
+ image: "{{ idem_image }}"
+ name: root-idempotency
+ state: present
+ command: 1h
+ register: info7
+
+- name: Check that it is recreated
+ assert:
+ that:
+ - info7 is not changed
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml
new file mode 100644
index 00000000..2178e522
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml
@@ -0,0 +1,103 @@
+- name: Test podman rootful container with networks
+ block:
+
+ - name: Remove container rootlessnet
+ containers.podman.podman_container:
+ name: rootlessnet
+ state: absent
+
+ - name: Run container with no specified networks
+ containers.podman.podman_container:
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+
+ - name: Run container again with no specified networks
+ containers.podman.podman_container:
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ register: info
+
+ - name: Check info for no specified networks
+ assert:
+ that:
+ - info is not changed
+
+ - name: Run container with network mode host
+ containers.podman.podman_container:
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network: host
+ register: info1
+
+ - name: Check info with network mode host
+ assert:
+ that:
+ - info1 is changed
+
+ - name: Run container with network mode host again
+ containers.podman.podman_container:
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network: host
+ register: info2
+
+ - name: Check info with network mode host again
+ assert:
+ that:
+ - info2 is not changed
+
+ - name: Run container without network at all
+ containers.podman.podman_container:
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network: none
+ register: info3
+
+ - name: Check info without network at all
+ assert:
+ that:
+ - info3 is changed
+
+ - name: Run container without network at all again
+ containers.podman.podman_container:
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network: none
+ register: info4
+
+ - name: Check info without network at all again
+ assert:
+ that:
+ - info4 is not changed
+
+ - name: Run container with default network mode
+ containers.podman.podman_container:
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ register: info5
+
+ - name: Check info with default network mode
+ assert:
+ that:
+ - info5 is changed
+
+ always:
+
+ - name: Delete all pods leftovers from tests
+ containers.podman.podman_container:
+ name: rootlessnet
+ state: absent
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_info/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_info/tasks/main.yml
new file mode 100644
index 00000000..7ad1e44c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_container_info/tasks/main.yml
@@ -0,0 +1,88 @@
+- name: Test podman_container_info
+ block:
+
+ - name: Generate random value for container name
+ set_fact:
+ container_name: "{{ 'ansible-test-podman-%0x' % ((2**32) | random) }}"
+
+ - name: Make sure container doesn't exist
+ command: podman container rm -f {{ container_name }}
+ ignore_errors: true
+
+ - name: Get missing container info
+ containers.podman.podman_container_info:
+ name: "{{ container_name }}"
+ register: nonexist
+
+ - name: Check results of missing container info
+ assert:
+ that:
+ - "'containers' in nonexist"
+ - nonexist is succeeded
+ - nonexist.containers == []
+
+ - name: Get missing multiple container info
+ containers.podman.podman_container_info:
+ name:
+ - "{{ container_name }}"
+ - neverexist
+ - whatever
+ register: nonexist2
+ ignore_errors: true
+
+ - name: Check results of missing multiple container info
+ assert:
+ that:
+ - "'containers' in nonexist2"
+ - nonexist2 is succeeded
+ - nonexist2.containers == []
+
+ - name: Make sure container exists
+ command: podman container run -d --name {{ container_name }} alpine sleep 15m
+
+ - name: Get existing container info
+ containers.podman.podman_container_info:
+ name: "{{ container_name }}"
+ register: existing_container
+
+ - name: Get mixed existing and non-existing container info
+ containers.podman.podman_container_info:
+ name:
+ - "{{ container_name }}"
+ - whatever
+ register: mixed_existing_container
+
+ - name: Get all containers info
+ containers.podman.podman_container_info:
+ register: all_containers
+
+ - name: Dump podman container inspect result
+ debug: var=existing_container
+
+ - name: Comparison with 'podman container inspect'
+ command: podman container inspect "{{ container_name }}"
+ register: podman_inspect
+
+ - name: Convert podman inspect output to JSON
+ set_fact:
+ podman_inspect_result: "{{ podman_inspect.stdout | from_json }}"
+
+ - name: Cleanup
+ command: podman container rm -f {{ container_name }}
+
+ - name: Make checks
+ assert:
+ that:
+ - "'containers' in existing_container"
+ - existing_container.containers
+ - "existing_container.containers == podman_inspect_result"
+ - all_containers.containers == existing_container.containers
+ - "'containers' in mixed_existing_container"
+ - mixed_existing_container.containers
+ - existing_container.containers == mixed_existing_container.containers
+
+ always:
+
+ - name: Cleanup
+ command: podman container rm -f {{ container_name }}
+ ignore_errors: true
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_containers/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_containers/tasks/main.yml
new file mode 100644
index 00000000..2703518c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_containers/tasks/main.yml
@@ -0,0 +1,642 @@
+- name: Test multiple podman_containers
+ block:
+ - name: Delete all containers leftovers from tests
+ containers.podman.podman_containers:
+ containers:
+ - name: "alpine:3.7"
+ state: absent
+ - name: "container"
+ state: absent
+ - name: "container1"
+ state: absent
+ - name: "container2"
+ state: absent
+ - name: "container3"
+ state: absent
+ - name: "container4"
+ state: absent
+ - name: "testidem"
+ state: absent
+ - name: "testidem1"
+ state: absent
+ - name: "testidem2"
+ state: absent
+ - name: "testidem3"
+ state: absent
+ - name: "testidem-pod"
+ state: absent
+ - name: "testidem-pod2"
+ state: absent
+
+ - name: Test no image with default action
+ containers.podman.podman_containers:
+ containers:
+ - name: "container"
+ - name: "container2"
+ - name: "container3"
+ image: alpine
+ ignore_errors: true
+ register: no_image
+
+ - name: Test no image with state 'started'
+ containers.podman.podman_containers:
+ containers:
+ - name: "container"
+ state: started
+ - name: "container2"
+ state: started
+ ignore_errors: true
+ register: no_image1
+
+ - name: Test no image with state 'present'
+ containers.podman.podman_containers:
+ containers:
+ - name: "container"
+ state: present
+ - name: "container2"
+ state: present
+ - name: "container3"
+ state: present
+ image: alpine
+ ignore_errors: true
+ register: no_image2
+
+ - name: Check no image
+ assert:
+ that:
+ - no_image is failed
+ - no_image1 is failed
+ - no_image2 is failed
+ - no_image.msg is search("State 'started' required image to be configured!")
+ - no_image1.msg is search ("State 'started' required image to be configured!")
+ - no_image2.msg is search("State 'present' required image to be configured!")
+ fail_msg: No-image test failed!
+ success_msg: No-image test passed!
+
+ - name: Ensure image doesn't exist
+ containers.podman.podman_image:
+ name: alpine:3.7
+ state: absent
+
+ - name: Check pulling image
+ containers.podman.podman_containers:
+ containers:
+ - name: container
+ image: alpine:3.7
+ state: present
+ command: sleep 1d
+ - name: container1
+ image: alpine:3.7
+ state: present
+ command: sleep 1d
+ register: image
+
+ - name: Check using already pulled image
+ containers.podman.podman_containers:
+ containers:
+ - name: container1
+ image: alpine:3.7
+ state: present
+ command: sleep 1d
+ - name: container3
+ image: alpine:3.7
+ state: present
+ command: sleep 1d
+ register: image2
+
+ - name: Check output is correct
+ assert:
+ that:
+ - image is changed
+ - image.containers[0] is defined
+ - image.containers[0]['State']['Running']
+ - image.containers[1] is defined
+ - image.containers[1]['State']['Running']
+ - "'pulled image alpine:3.7' in image.actions"
+ - "'started container' in image.actions"
+ - "'started container1' in image.actions"
+ - image2 is changed
+ - image2.containers is defined
+ - image2.containers[0]['State']['Running']
+ - image2.containers[1]['State']['Running']
+ - "'pulled image alpine:3.7' not in image2.actions"
+ - "'started container3' in image2.actions"
+ fail_msg: Pulling image test failed!
+ success_msg: Pulling image test passed!
+
+ - name: Check failed image pull
+ containers.podman.podman_containers:
+ containers:
+ - name: container1
+ image: alpine:3.7
+ state: present
+ command: sleep 1d
+ - name: container
+ image: ineverneverneverexist
+ state: present
+ command: sleep 1d
+ register: imagefail
+ ignore_errors: true
+
+ - name: Check output is correct
+ assert:
+ that:
+ - imagefail is failed
+ - imagefail.msg == "Can't pull image ineverneverneverexist"
+
+ - name: Force containers recreate
+ containers.podman.podman_containers:
+ containers:
+ - name: container1
+ image: alpine:3.7
+ state: present
+ command: sleep 1d
+ - name: container
+ image: alpine
+ state: present
+ command: sleep 1d
+ recreate: true
+ register: recreated
+
+ - name: Check output is correct
+ assert:
+ that:
+ - recreated is changed
+ - recreated.containers is defined
+ - recreated.containers[1]['State']['Running']
+ - "'recreated container' in recreated.actions"
+ fail_msg: Force recreate test failed!
+ success_msg: Force recreate test passed!
+
+ - name: Stop containers
+ containers.podman.podman_containers:
+ containers:
+ - name: container
+ state: stopped
+ - name: container1
+ state: stopped
+ register: stopped
+
+ - name: Stop the same containers again (idempotency)
+ containers.podman.podman_containers:
+ containers:
+ - name: container
+ state: stopped
+ - name: container1
+ state: stopped
+ register: stopped_again
+
+ - name: Check output is correct
+ assert:
+ that:
+ - stopped is changed
+ - stopped.containers is defined
+ - not stopped.containers[0]['State']['Running']
+ - not stopped.containers[1]['State']['Running']
+ - "'stopped container' in stopped.actions"
+ - stopped_again is not changed
+ - stopped_again.containers is defined
+ - not stopped_again.containers[0]['State']['Running']
+ - not stopped_again.containers[1]['State']['Running']
+ - stopped_again.actions == []
+ fail_msg: Stopping container test failed!
+ success_msg: Stopping container test passed!
+
+ - name: Delete stopped containers
+ containers.podman.podman_containers:
+ containers:
+ - name: container
+ state: absent
+ - name: container1
+ state: absent
+ register: deleted
+
+ - name: Delete again containers (idempotency)
+ containers.podman.podman_containers:
+ containers:
+ - name: container
+ state: absent
+ - name: container1
+ state: absent
+ register: deleted_again
+
+ - name: Check output is correct
+ assert:
+ that:
+ - deleted is changed
+ - deleted.containers is defined
+ - deleted.containers == []
+ - "'deleted container' in deleted.actions"
+ - "'deleted container1' in deleted.actions"
+ - deleted_again is not changed
+ - deleted_again.containers is defined
+ - deleted_again.containers == []
+ - deleted_again.actions == []
+ fail_msg: Deleting stopped container test failed!
+ success_msg: Deleting stopped container test passed!
+
+ - name: Create containers, but don't run
+ containers.podman.podman_containers:
+ containers:
+ - name: container
+ image: alpine:3.7
+ state: stopped
+ command: sleep 1d
+ - name: container1
+ image: alpine:3.7
+ state: stopped
+ command: sleep 1d
+ register: created
+
+ - name: Create containers, but don't run again
+ containers.podman.podman_containers:
+ containers:
+ - name: container
+ image: alpine:3.7
+ state: stopped
+ command: sleep 1d
+ - name: container1
+ image: alpine:3.7
+ state: stopped
+ command: sleep 1d
+ register: created_again
+
+ - name: Check output is correct
+ assert:
+ that:
+ - created is changed
+ - created.containers is defined
+ - created.containers != []
+ - not created.containers[0]['State']['Running']
+ - not created.containers[1]['State']['Running']
+ - "'created container' in created.actions"
+ fail_msg: "Creating stopped container test failed!"
+ success_msg: "Creating stopped container test passed!"
+
+ - name: Delete created containers
+ containers.podman.podman_containers:
+ containers:
+ - name: container
+ state: absent
+ - name: container1
+ state: absent
+
+ - name: Start containers that were deleted
+ containers.podman.podman_containers:
+ containers:
+ - name: container
+ image: alpine:3.7
+ state: started
+ command: sleep 1d
+ - name: container1
+ image: alpine:3.7
+ state: started
+ command: sleep 1d
+ register: started
+
+ - name: Check output is correct
+ assert:
+ that:
+ - started.containers is defined
+ - started.containers[0]['State']['Running']
+ - started.containers[1]['State']['Running']
+ - "'started container' in started.actions"
+ - "'pulled image alpine:3.7' not in started.actions"
+
+ - name: Delete started container
+ containers.podman.podman_containers:
+ containers:
+ - name: container
+ state: absent
+ - name: container1
+ state: absent
+ register: deleted
+
+ - name: Delete again container (idempotency)
+ containers.podman.podman_containers:
+ containers:
+ - name: container
+ state: absent
+ - name: container1
+ state: absent
+ register: deleted_again
+
+ - name: Check output is correct
+ assert:
+ that:
+ - deleted is changed
+ - deleted.containers is defined
+ - deleted.containers == []
+ - "'deleted container' in deleted.actions"
+ - "'deleted container1' in deleted.actions"
+ - deleted_again is not changed
+ - deleted_again.containers is defined
+ - deleted_again.containers == []
+ - deleted_again.actions == []
+ fail_msg: Deleting started container test failed!
+ success_msg: Deleting started container test passed!
+
+ - name: Recreate container with parameters
+ containers.podman.podman_containers:
+ containers:
+ - name: container
+ image: docker.io/alpine:3.7
+ state: started
+ command: sleep 1d
+ recreate: true
+ etc_hosts:
+ host1: 127.0.0.1
+ host2: 127.0.0.1
+ annotation:
+ this: "annotation_value"
+ dns_servers:
+ - 1.1.1.1
+ - 8.8.4.4
+ dns_search_domains: example.com
+ capabilities:
+ - SYS_TIME
+ - NET_ADMIN
+ ports:
+ - "9000:80"
+ - "9001:8000"
+ workdir: "/bin"
+ env:
+ FOO: bar=1
+ BAR: foo
+ TEST: 1
+ BOOL: false
+ label:
+ somelabel: labelvalue
+ otheralbe: othervalue
+ volumes:
+ - /tmp:/data
+ - name: container1
+ image: docker.io/alpine:3.7
+ state: started
+ command: sleep 1d
+ recreate: true
+ etc_hosts:
+ host1: 127.0.0.1
+ host2: 127.0.0.1
+ annotation:
+ this: "annotation_value"
+ dns_servers:
+ - 1.1.1.1
+ - 8.8.4.4
+ dns_search_domains: example.com
+ capabilities:
+ - SYS_TIME
+ - NET_ADMIN
+ ports:
+ - "9002:80"
+ - "9003:8000"
+ workdir: "/bin"
+ env:
+ FOO: bar=1
+ BAR: foo
+ TEST: 1
+ BOOL: false
+ label:
+ somelabel: labelvalue
+ otheralbe: othervalue
+ volumes:
+ - /tmp:/data
+ register: test
+
+ - name: Check output is correct
+ assert:
+ that:
+ - test is changed
+ - test.containers is defined
+ - test.containers != []
+ - test.containers[0]['State']['Running']
+ # test capabilities
+ - "'CAP_SYS_TIME' in test.containers[0]['BoundingCaps']"
+ - "'CAP_NET_ADMIN' in test.containers[0]['BoundingCaps']"
+ # test annotations
+ - test.containers[0]['Config']['Annotations']['this'] is defined
+ - test.containers[0]['Config']['Annotations']['this'] == "annotation_value"
+ # test DNS
+ - >-
+ (test.containers[0]['HostConfig']['Dns'] is defined and
+ test.containers[0]['HostConfig']['Dns'] == ['1.1.1.1', '8.8.4.4']) or
+ (test.containers[0]['HostConfig']['DNS'] is defined and
+ test.containers[0]['HostConfig']['DNS'] == ['1.1.1.1', '8.8.4.4'])
+ # test ports
+ - test.containers[0]['NetworkSettings']['Ports']|length == 2
+ # test working dir
+ - test.containers[0]['Config']['WorkingDir'] == "/bin"
+ # test dns search
+ - >-
+ (test.containers[0]['HostConfig']['DnsSearch'] is defined and
+ test.containers[0]['HostConfig']['DnsSearch'] == ['example.com']) or
+ (test.containers[0]['HostConfig']['DNSSearch'] is defined and
+ test.containers[0]['HostConfig']['DNSSearch'] == ['example.com'])
+ # test environment variables
+ - "'FOO=bar=1' in test.containers[0]['Config']['Env']"
+ - "'BAR=foo' in test.containers[0]['Config']['Env']"
+ - "'TEST=1' in test.containers[0]['Config']['Env']"
+ - "'BOOL=False' in test.containers[0]['Config']['Env']"
+ # test labels
+ - test.containers[0]['Config']['Labels'] | length == 2
+ - test.containers[0]['Config']['Labels']['somelabel'] == "labelvalue"
+ - test.containers[0]['Config']['Labels']['otheralbe'] == "othervalue"
+ # test mounts
+ - >-
+ (test.containers[0]['Mounts'][0]['Destination'] is defined and
+ '/data' in test.containers[0]['Mounts'] | map(attribute='Destination') | list) or
+ (test.containers[0]['Mounts'][0]['destination'] is defined and
+ '/data' in test.containers[0]['Mounts'] | map(attribute='destination') | list)
+ - >-
+ (test.containers[0]['Mounts'][0]['Source'] is defined and
+ '/tmp' in test.containers[0]['Mounts'] | map(attribute='Source') | list) or
+ (test.containers[0]['Mounts'][0]['source'] is defined and
+ '/tmp' in test.containers[0]['Mounts'] | map(attribute='source') | list)
+ fail_msg: Parameters container test failed!
+ success_msg: Parameters container test passed!
+
+ - name: Check basic idempotency of running container
+ containers.podman.podman_containers:
+ containers:
+ - name: testidem
+ image: docker.io/alpine
+ state: present
+ command: sleep 20m
+ - name: testidem2
+ image: docker.io/alpine
+ state: present
+ command: sleep 21m
+ - name: testidem3
+ image: docker.io/alpine
+ state: present
+ command: sleep 22m
+
+ - name: Check basic idempotency of running container - run it again
+ containers.podman.podman_containers:
+ containers:
+ - name: testidem
+ image: docker.io/alpine
+ state: present
+ command: sleep 20m
+ - name: testidem2
+ image: docker.io/alpine
+ state: present
+ command: sleep 21m
+ - name: testidem3
+ image: docker.io/alpine
+ state: present
+ command: sleep 22m
+ register: idem
+
+ - name: Check that nothing was changed
+ assert:
+ that:
+ - not idem.changed
+
+ - name: Run changed container (with tty enabled)
+ containers.podman.podman_containers:
+ containers:
+ - name: testidem
+ image: docker.io/alpine
+ state: present
+ command: sleep 20m
+ tty: true
+ - name: testidem2
+ image: docker.io/alpine
+ state: present
+ command: sleep 21m
+ - name: testidem3
+ image: docker.io/alpine
+ state: present
+ command: sleep 22m
+ register: idem1
+
+ - name: Check that container is recreated when changed
+ assert:
+ that:
+ - idem1 is changed
+
+ - name: Run changed container without specifying an option, use defaults
+ containers.podman.podman_containers:
+ containers:
+ - name: testidem
+ image: docker.io/alpine
+ state: present
+ command: sleep 20m
+ - name: testidem2
+ image: docker.io/alpine
+ state: present
+ command: sleep 21m
+ - name: testidem3
+ image: docker.io/alpine
+ state: present
+ command: sleep 22m
+ register: idem2
+
+ - name: Check that container is recreated when changed to default value
+ assert:
+ that:
+ - idem2 is changed
+
+ - name: Remove container
+ containers.podman.podman_containers:
+ containers:
+ - name: testidem
+ state: absent
+ register: remove
+
+ - name: Check podman_actions
+ assert:
+ that:
+ - "'podman rm -f testidem' in remove.podman_actions"
+
+ - name: Create a pod
+ containers.podman.podman_pod:
+ name: testidempod
+
+ - name: Check basic idempotency of pod container
+ containers.podman.podman_containers:
+ containers:
+ - name: testidem-pod
+ image: docker.io/alpine
+ state: present
+ command: sleep 20m
+ pod: "testidempod"
+ - name: testidem-pod2
+ image: docker.io/alpine
+ state: present
+ command: sleep 20m
+ pod: testidempod
+
+ - name: Check basic idempotency of pod container - run it again
+ containers.podman.podman_containers:
+ containers:
+ - name: testidem-pod
+ image: alpine:latest
+ state: present
+ command: sleep 20m
+ pod: testidempod
+ - name: testidem-pod2
+ image: docker.io/alpine
+ state: present
+ command: sleep 20m
+ pod: testidempod
+ register: idem
+
+ - name: Check that nothing was changed in pod containers
+ assert:
+ that:
+ - not idem.changed
+
+ - name: Run changed pod container (with tty enabled)
+ containers.podman.podman_containers:
+ containers:
+ - name: testidem-pod
+ image: alpine
+ state: present
+ command: sleep 20m
+ tty: true
+ pod: testidempod
+ - name: testidem-pod2
+ image: alpine
+ state: present
+ command: sleep 20m
+ pod: testidempod
+ register: idem1
+
+ - name: Check that container is recreated when changed
+ assert:
+ that:
+ - idem1 is changed
+
+ - name: Remove container
+ containers.podman.podman_containers:
+ containers:
+ - name: testidem-pod
+ state: absent
+ - name: testidem-pod2
+ state: absent
+
+ always:
+ - name: Delete all container leftovers from tests
+ containers.podman.podman_container:
+ name: "{{ item }}"
+ state: absent
+ loop:
+ - "alpine:3.7"
+ - "container"
+ - "container1"
+ - "container2"
+ - "container3"
+ - "container4"
+ - "testidem"
+ - "testidem1"
+ - "testidem2"
+ - "testidem3"
+ - "testidem-pod"
+ - "testidem-pod2"
+
+ - name: Remove pod
+ containers.podman.podman_pod:
+ name: testidempod
+ state: absent
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_image/files/Containerfile b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_image/files/Containerfile
new file mode 100644
index 00000000..d4bd8edb
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_image/files/Containerfile
@@ -0,0 +1,3 @@
+FROM quay.io/coreos/alpine-sh
+ENV VAR testing
+WORKDIR ${VAR}
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml
new file mode 100644
index 00000000..e0eb1961
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml
@@ -0,0 +1,190 @@
+- name: Test podman_image
+ block:
+ - name: Pull image
+ containers.podman.podman_image:
+ name: quay.io/coreos/alpine-sh
+ register: pull1
+
+ - name: Pull image again
+ containers.podman.podman_image:
+ name: quay.io/coreos/alpine-sh
+ register: pull2
+
+ - name: Pull image from docker.io with short url
+ containers.podman.podman_image:
+ name: docker.io/alpine
+ register: pull3
+
+ - name: Pull image from docker.io with short url again
+ containers.podman.podman_image:
+ name: docker.io/alpine
+ register: pull4
+
+ - name: Pull image from docker.io with official/normalised url again
+ containers.podman.podman_image:
+ name: docker.io/library/alpine
+ register: pull5
+
+ - name: List images
+ command: podman image ls
+ register: images
+
+ - name: Ensure image were pulled properly
+ assert:
+ that:
+ - pull1 is changed
+ - pull2 is not changed
+ - pull3 is changed
+ - pull4 is changed
+ - pull5 is not changed
+ - "'alpine-sh' in images.stdout"
+ - "'library/alpine' in images.stdout"
+
+ - name: add another tag (repository url)
+ command:
+ argv:
+ - podman
+ - tag
+ - quay.io/coreos/alpine-sh
+ - quay.io/coreos/library/alpine-sh
+
+ - name: Remove image (tag)
+ containers.podman.podman_image:
+ name: quay.io/coreos/alpine-sh
+ state: absent
+ register: rmi1
+
+ - name: Remove image again
+ containers.podman.podman_image:
+ name: quay.io/coreos/alpine-sh
+ state: absent
+ register: rmi2
+
+ - name: Remove image using new repository url
+ containers.podman.podman_image:
+ name: quay.io/coreos/library/alpine-sh
+ state: absent
+ register: rmi3
+
+ - name: Try to remove docker.io image using short url
+ containers.podman.podman_image:
+ name: docker.io/alpine
+ state: absent
+ register: rmi4
+
+ - name: Remove docker.io image using normalised url
+ containers.podman.podman_image:
+ name: docker.io/library/alpine
+ state: absent
+ register: rmi5
+
+ - name: List images
+ command: podman image ls
+ register: images
+
+ - name: Ensure image were removed properly
+ assert:
+ that:
+ - rmi1 is changed
+ - rmi2 is not changed
+ - rmi3 is changed
+ - rmi4 is not changed
+ - rmi5 is changed
+ - "'alpine-sh' not in images.stdout"
+ - "'library/alpine' not in images.stdout"
+
+ - name: Pull a specific version of an image
+ containers.podman.podman_image:
+ name: quay.io/coreos/etcd
+ tag: v3.3.11
+ register: specific_image1
+
+ - name: Pull a specific version of an image again
+ containers.podman.podman_image:
+ name: quay.io/coreos/etcd
+ tag: v3.3.11
+ register: specific_image2
+
+ - name: List images
+ command: podman image ls
+ register: images
+
+ - name: Ensure specific image was pulled properly
+ assert:
+ that:
+ - specific_image1 is changed
+ - specific_image2 is not changed
+ - "'v3.3.11' in images.stdout"
+
+ - name: Create a build dir
+ file:
+ path: /var/tmp/build
+ state: directory
+
+ - name: Copy Containerfile
+ copy:
+ src: Containerfile
+ dest: /var/tmp/build/Dockerfile
+
+ - name: Build OCI image
+ containers.podman.podman_image:
+ name: testimage
+ path: /var/tmp/build
+ register: oci_build1
+
+ - name: Build OCI image again
+ containers.podman.podman_image:
+ name: testimage
+ path: /var/tmp/build
+ register: oci_build2
+
+ - name: Inspect build image
+ containers.podman.podman_image_info:
+ name: testimage
+ register: testimage_info
+
+ - name: Ensure OCI image was built properly
+ assert:
+ that:
+ - oci_build1 is changed
+ - oci_build2 is not changed
+ - "'localhost/testimage:latest' in testimage_info.images[0]['RepoTags'][0]"
+
+ - name: Build Docker image
+ containers.podman.podman_image:
+ name: dockerimage
+ path: /var/tmp/build
+ build:
+ format: docker
+ register: docker_build1
+
+ - name: Build Docker image again
+ containers.podman.podman_image:
+ name: dockerimage
+ path: /var/tmp/build
+ build:
+ format: docker
+ register: docker_build2
+
+ - name: Inspect build image
+ containers.podman.podman_image_info:
+ name: dockerimage
+ register: dockerimage_info
+
+ - name: Ensure Docker image was built properly
+ assert:
+ that:
+ - docker_build1 is changed
+ - docker_build2 is not changed
+ - "'localhost/dockerimage:latest' in dockerimage_info.images[0]['RepoTags'][0]"
+
+ always:
+ - name: Cleanup images
+ containers.podman.podman_image:
+ name: "{{ item }}"
+ state: absent
+ loop:
+ - quay.io/coreos/alpine-sh
+ - quay.io/coreos/etcd:v3.3.11
+ - localhost/testimage
+ - localhost/dockerimage
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_image_info/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_image_info/tasks/main.yml
new file mode 100644
index 00000000..c9bd0f83
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_image_info/tasks/main.yml
@@ -0,0 +1,50 @@
+- name: Test podman_image_info
+ block:
+ - name: Pull image
+ command: podman pull quay.io/coreos/etcd
+
+ - name: Get info on all images
+ containers.podman.podman_image_info:
+ register: all_image_result
+
+ - name: Pull another image
+ command: podman pull quay.io/coreos/dnsmasq
+
+ - name: Get info on specific image
+ containers.podman.podman_image_info:
+ name: dnsmasq
+ register: named_image_result
+
+ - name:
+ assert:
+ that:
+ - all_image_result.images | length > 0
+ - named_image_result.images | length == 1
+ - "'dnsmasq' in named_image_result.images[0]['RepoTags'][0]"
+
+ - name: Get info on single image that does not exist
+ containers.podman.podman_image_info:
+ name: nope
+ register: single_nonexistant
+
+ - name: Get info on multiple images that do not exist
+ containers.podman.podman_image_info:
+ name:
+ - nope
+ - reallynope
+ register: multiple_nonexistant
+
+ - name: Get info with one image that does not exist
+ containers.podman.podman_image_info:
+ name:
+ - dnsmasq
+ - nope
+ - etcd
+ register: mixed_nonexistant
+
+ - name: Ensure image info was returned when non-existant image info was requisted
+ assert:
+ that:
+ - single_nonexistant.images | length == 0
+ - multiple_nonexistant.images | length == 0
+ - mixed_nonexistant.images | length == 2
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_login_info/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_login_info/tasks/main.yml
new file mode 100644
index 00000000..020c8446
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_login_info/tasks/main.yml
@@ -0,0 +1,62 @@
+- name: Test podman_login_info
+ block:
+
+ - name: Print podman version
+ command: podman version
+
+ - name: Get login info with invalid executable
+ containers.podman.podman_login_info:
+ executable: podman_invalid
+ registry: quay.io
+ register: invalid_executable
+ ignore_errors: yes
+
+ - name: Check invalid executable results
+ assert:
+ that:
+ - invalid_executable is failed
+
+ - name: Get login info without specifying registry
+ containers.podman.podman_login_info:
+ executable: podman_invalid
+ register: missing_registry
+ ignore_errors: yes
+
+ - name: Check missing registry results
+ assert:
+ that:
+ - missing_registry is failed
+
+ - name: Get login info for a non-existing registry
+ containers.podman.podman_login_info:
+ registry: non-existing.registry
+ register: non_existing_registry
+
+ - name: Check non-existing registry results
+ assert:
+ that:
+ - "'login' in non_existing_registry"
+ - non_existing_registry.login
+ - "'registry' in non_existing_registry.login"
+ - "'username' in non_existing_registry.login"
+ - "'logged_in' in non_existing_registry.login"
+ - "non_existing_registry.login.registry == 'non-existing.registry'"
+ - "non_existing_registry.login.username == ''"
+ - "non_existing_registry.login.logged_in == False"
+
+ - name: Get login info for a non-existing authfile
+ # This will return not logged in even if logged in via different authfile
+ containers.podman.podman_login_info:
+ registry: quay.io
+ authfile: non-existing.authfile.json
+ register: non_existing_authfile
+
+ - name: Check non-existing authfile results
+ assert:
+ that:
+ - "'login' in non_existing_authfile"
+ - non_existing_authfile.login
+ - "'username' in non_existing_authfile.login"
+ - "'logged_in' in non_existing_authfile.login"
+ - "non_existing_authfile.login.username == ''"
+ - "non_existing_authfile.login.logged_in == False"
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_logout/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_logout/tasks/main.yml
new file mode 100644
index 00000000..c2f7d47f
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_logout/tasks/main.yml
@@ -0,0 +1,52 @@
+- name: Test podman_logout
+ block:
+
+ - name: Print podman version
+ command: podman version
+
+ - name: Logout from docker if it exists
+ command: docker logout
+ ignore_errors: true
+
+ - name: Log out with invalid executable
+ containers.podman.podman_logout:
+ executable: podman_invalid
+ register: invalid_executable
+ ignore_errors: yes
+
+ - name: Check invalid executable results
+ assert:
+ that:
+ - invalid_executable is failed
+
+ - name: Log out of non-existing registry
+ containers.podman.podman_logout:
+ register: non_existing_registry
+
+ - name: Check results
+ assert:
+ that:
+ - "'changed' in non_existing_registry"
+ - "non_existing_registry.changed == False"
+
+ - name: Log out with invalid authfile
+ containers.podman.podman_logout:
+ authfile: authfile_invalid.json
+ register: invalid_authfile
+ ignore_errors: yes
+
+ - name: Check invalid authfile results
+ assert:
+ that:
+ - invalid_authfile is failed
+
+ - name: Log out of all registries
+ containers.podman.podman_logout:
+ all: yes
+ register: all_registries
+
+ - name: Check results
+ assert:
+ that:
+ - "'changed' in all_registries"
+ - "all_registries.changed == True"
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml
new file mode 100644
index 00000000..488ad2b3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml
@@ -0,0 +1,224 @@
+- name: Test podman_network
+ become: true
+ block:
+
+ - name: Print podman version
+ command: podman version
+
+ - name: Check if dnsname plugin is installed
+ block:
+
+ - name: Check if plugin is installed
+ stat:
+ path: "{{ item }}"
+ loop:
+ - /usr/libexec/cni/dnsname
+ - /usr/lib/cni/dnsname
+ - /opt/cni/bin/dnsname
+ - /opt/bridge/bin/dnsname
+ register: plugin_results
+
+ - name: Set plugin fact
+ set_fact:
+ dns_plugin: "{{ true in plugin_results.results|map(attribute='stat.exists') }}"
+
+ - name: Generate random value for network name
+ set_fact:
+ network_name: "{{ 'ansible-test-podman-%0x' % ((2**32) | random) }}"
+
+ - name: Make sure network doesn't exist
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: absent
+
+ - name: Get missing network info
+ containers.podman.podman_network_info:
+ name: "{{ network_name }}"
+ register: info
+ ignore_errors: true
+
+ - name: Check results
+ assert:
+ that:
+ - info is failed
+
+ - name: Create network
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ register: net
+
+ - name: Get existing network info
+ containers.podman.podman_network_info:
+ name: "{{ network_name }}"
+ register: info1
+
+ - name: Check info
+ assert:
+ that:
+ - info1 | length > 1
+ - info1.networks.0.name == network_name
+ - net is changed
+
+ - name: Create network again
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: present
+ register: info2
+
+ - name: Check info
+ assert:
+ that:
+ - info2 is not changed
+
+ - name: Create network with disable DNS
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: present
+ disable_dns: true
+ register: info3
+
+ - name: Check info
+ assert:
+ that:
+ - >-
+ info3 is changed and dns_plugin|bool or
+ info3 is not changed and not dns_plugin|bool
+
+ - name: Create network with disable DNS again
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: present
+ disable_dns: true
+ register: info4
+
+ - name: Check info
+ assert:
+ that:
+ - info4 is not changed
+
+ - name: Create network w/o disable DNS
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: present
+ register: info5
+
+ - name: Check info
+ assert:
+ that:
+ - >-
+ info5 is changed and dns_plugin|bool or
+ info5 is not changed and not dns_plugin|bool
+
+ - name: Create network with custom gateway
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: present
+ gateway: 10.100.100.100
+ subnet: 10.100.100.0/24
+ register: info6
+
+ - name: Check info
+ assert:
+ that:
+ - info6 is changed
+
+ - name: Create network with custom gateway again
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: present
+ gateway: 10.100.100.100
+ subnet: 10.100.100.0/24
+ register: info7
+
+ - name: Check info
+ assert:
+ that:
+ - info7 is not changed
+
+ - name: Create internal network
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: present
+ internal: true
+ register: info9
+
+ - name: Check info
+ assert:
+ that:
+ - info9 is changed
+
+ - name: Create internal network again
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: present
+ internal: true
+ register: info10
+
+ - name: Check info
+ assert:
+ that:
+ - info10 is not changed
+
+ - name: Create a regular external network
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: present
+ register: info11
+
+ - name: Check info
+ assert:
+ that:
+ - info11 is changed
+
+ - name: Create network with subnet
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: present
+ subnet: 10.200.200.0/24
+ register: info12
+
+ - name: Check info
+ assert:
+ that:
+ - info12 is changed
+
+ - name: Create network with subnet again
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: present
+ subnet: 10.200.200.0/24
+ register: info13
+
+ - name: Check info
+ assert:
+ that:
+ - info13 is not changed
+
+ - name: Create network with ipv6 subnet
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: present
+ subnet: 2001:cafe::/64
+ ipv6: true
+
+ - name: Make sure network doesn't exist
+ containers.podman.podman_network:
+ name: "{{ network_name }}"
+ state: absent
+
+ - name: Get existing network info
+ containers.podman.podman_network_info:
+ name: "{{ network_name }}"
+ register: info100
+ ignore_errors: true
+
+ - name: Check results
+ assert:
+ that:
+ - info100 is failed
+
+ always:
+
+ - name: Cleanup
+ command: podman network rm -f {{ network_name }}
+ ignore_errors: true
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_network_info/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_network_info/tasks/main.yml
new file mode 100644
index 00000000..81bcaa30
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_network_info/tasks/main.yml
@@ -0,0 +1,60 @@
+- name: Test podman_network_info
+ become: true
+ block:
+
+ - name: Print podman version
+ command: podman version
+
+ - name: Generate random value for network name
+ set_fact:
+ network_name: "{{ 'ansible-test-podman-%0x' % ((2**32) | random) }}"
+
+ - name: Make sure network doesn't exist
+ command: podman network rm {{ network_name }}
+ ignore_errors: true
+
+ - name: Get missing network info
+ containers.podman.podman_network_info:
+ name: "{{ network_name }}"
+ register: nonexist
+ ignore_errors: true
+
+ - name: Check results
+ assert:
+ that:
+ - "'networks' not in nonexist"
+ - nonexist is failed
+
+ - name: Make sure network exists
+ command: podman network create {{ network_name }}
+
+ - name: Get existing network info
+ containers.podman.podman_network_info:
+ name: "{{ network_name }}"
+ register: existing_network
+
+ - name: Dump podman network inspect result
+ debug: var=existing_network
+
+ - name: Comparison with 'podman network inspect'
+ command: podman network inspect "{{ network_name }}"
+ register: podman_inspect
+
+ - name: Convert podman inspect output to JSON
+ set_fact:
+ podman_inspect_result: "{{ podman_inspect.stdout | from_json }}"
+
+ - name: Cleanup
+ command: podman network rm {{ network_name }}
+
+ - name: Make checks
+ assert:
+ that:
+ - "'networks' in existing_network"
+ - existing_network.networks
+ - "existing_network.networks == podman_inspect_result"
+ always:
+
+ - name: Cleanup
+ command: podman network rm {{ network_name }}
+ ignore_errors: true
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml
new file mode 100644
index 00000000..2ede24bd
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml
@@ -0,0 +1,613 @@
+- name: Test podman pod
+ block:
+
+ - name: Discover podman version
+ shell: podman version | grep "^Version:" | awk {'print $2'}
+ register: podman_v
+
+ - name: Set podman version to 1
+ set_fact:
+ podman_version: 1
+ when: podman_v.stdout is version('2.0.0', 'lt')
+
+ - name: Set podman version to 2
+ set_fact:
+ podman_version: 2
+ when: podman_v.stdout is version('2.0.0', '>=')
+
+ - name: Discover cgroups version
+ shell: podman info | grep cgroupVersion | awk {'print $2'}
+ register: cgroups
+
+ - name: Set cgroups version
+ set_fact:
+ cgroups_version: "{{ cgroups.stdout }}"
+
+ - name: Delete all pods leftovers from tests
+ containers.podman.podman_pod:
+ name: "{{ item }}"
+ state: absent
+ loop:
+ - "pod1"
+ - "pod2"
+
+ - name: Create pod
+ containers.podman.podman_pod:
+ name: pod1
+ state: created
+ register: pod1_info
+
+ - name: Check info
+ assert:
+ that:
+ - >-
+ (pod1_info.pod['State']['status'] is defined and
+ pod1_info.pod['State']['status'] == 'Created') or
+ (pod1_info.pod['State']['status'] is not defined and
+ pod1_info.pod['State'] == 'Created')
+
+ - name: Start pod
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ register: pod2_info
+
+ - name: Check info
+ assert:
+ that:
+ - >-
+ (pod2_info.pod['State']['status'] is defined and
+ pod2_info.pod['State']['status'] == 'Running') or
+ (pod2_info.pod['State']['status'] is not defined and
+ pod2_info.pod['State'] == 'Running')
+
+ - name: Pause pod
+ containers.podman.podman_pod:
+ name: pod1
+ state: paused
+ register: pod3_info
+ when: cgroups_version == 'v2'
+
+ - name: Check info
+ assert:
+ that:
+ - >-
+ (pod3_info.pod['State']['status'] is defined and
+ pod3_info.pod['State']['status'] == 'Paused') or
+ (pod3_info.pod['State']['status'] is not defined and
+ pod3_info.pod['State'] == 'Paused')
+ when: cgroups_version == 'v2'
+
+ - name: Unpause pod
+ containers.podman.podman_pod:
+ name: pod1
+ state: unpaused
+ register: pod4_info
+ when: cgroups_version == 'v2'
+
+ - name: Check info
+ assert:
+ that:
+ - >-
+ (pod4_info.pod['State']['status'] is defined and
+ pod4_info.pod['State']['status'] == 'Running') or
+ (pod4_info.pod['State']['status'] is not defined and
+ pod4_info.pod['State'] == 'Running')
+ when: cgroups_version == 'v2'
+
+ - name: Stop pod
+ containers.podman.podman_pod:
+ name: pod1
+ state: stopped
+ register: pod5_info
+
+ - name: Check info
+ assert:
+ that:
+ - >-
+ (pod5_info.pod['State']['status'] is defined and
+ pod5_info.pod['State']['status'] != 'Running') or
+ (pod5_info.pod['State']['status'] is not defined and
+ pod5_info.pod['State'] != 'Running')
+
+ - name: Kill pod
+ containers.podman.podman_pod:
+ name: pod1
+ state: killed
+ register: pod6_info
+
+ - name: Check info
+ assert:
+ that:
+ - >-
+ (pod6_info.pod['State']['status'] is defined and
+ pod6_info.pod['State']['status'] == 'Exited') or
+ (pod6_info.pod['State']['status'] is not defined and
+ pod6_info.pod['State'] == 'Exited')
+
+ - name: Start pod
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ register: pod7_info
+
+ - name: Check info
+ assert:
+ that:
+ - >-
+ (pod7_info.pod['State']['status'] is defined and
+ pod7_info.pod['State']['status'] == 'Running') or
+ (pod7_info.pod['State']['status'] is not defined and
+ pod7_info.pod['State'] == 'Running')
+
+ - name: Start pod again for idempotency
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ register: pod8_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod8_info is not changed
+
+ - name: Start pod with ports
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ ports:
+ - "4444:4444/tcp"
+ - "1212:5555"
+ - "8888:19191/udp"
+ - "1900:1900/udp"
+ - "127.0.0.1:7671:7676/udp"
+ - "127.0.0.1:12122:8876/udp"
+ - "127.0.0.1:13122:8871/tcp"
+ - "127.0.0.1:43423:8872"
+ register: pod9_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod9_info is changed
+
+ - name: Start pod with ports for idempotency
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ ports:
+ - "4444:4444/tcp"
+ - "1212:5555"
+ - "8888:19191/udp"
+ - "1900:1900/udp"
+ - "127.0.0.1:7671:7676/udp"
+ - "127.0.0.1:12122:8876/udp"
+ - "127.0.0.1:13122:8871/tcp"
+ - "127.0.0.1:43423:8872"
+ register: pod10_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod10_info is not changed
+
+ - name: Start pod again for idempotency
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ register: pod11_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod11_info is changed
+
+ - name: Start pod with share
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ share: uts
+ register: pod12_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod12_info is changed
+
+ - name: Start pod with share for idempotency
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ share: uts
+ register: pod13_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod13_info is not changed
+
+ - name: Start pod without shares
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ share: ""
+ register: pod14_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod14_info is changed
+
+ - name: Start pod with default shares
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ register: pod15_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod15_info is changed
+
+ - name: Start pod with labels
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ label:
+ key: cval
+ otherkey: kddkdk
+ somekey: someval
+ register: pod16_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod16_info is changed
+
+ - name: Start pod with labels again for idempotency
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ label:
+ key: cval
+ otherkey: kddkdk
+ somekey: someval
+ register: pod17_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod17_info is not changed
+
+ - name: Start pod with different labels
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ label:
+ key: cval
+ otherkey: 23434dfsd
+ somekey: someval
+ register: pod18_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod18_info is changed
+
+ - name: Start pod without labels
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ register: pod19_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod19_info is changed
+
+ - name: Start pod with dns and hosts settings
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ add_host:
+ - "google:8.8.8.8"
+ - "site1:127.0.0.1"
+ dns:
+ - 1.1.1.1
+ dns_opt:
+ - "option timeout:3"
+ dns_search:
+ - "redhat.com"
+ - "ibm.com"
+ hostname: happypod
+ register: pod20_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod20_info is changed
+
+ - name: Start pod with dns and hosts settings again
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ add_host:
+ - "google:8.8.8.8"
+ - "site1:127.0.0.1"
+ dns:
+ - 1.1.1.1
+ dns_opt:
+ - "option timeout:3"
+ dns_search:
+ - "redhat.com"
+ - "ibm.com"
+ hostname: happypod
+ register: pod21_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod21_info is not changed
+
+ - name: Start pod with changed dns
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ add_host:
+ - "google:8.8.8.8"
+ - "site1:127.0.0.1"
+ dns:
+ - 1.1.1.1
+ - 2.2.2.2
+ dns_opt:
+ - "option timeout:3"
+ dns_search:
+ - "redhat.com"
+ - "ibm.com"
+ hostname: happypod
+ register: pod22_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod22_info is changed
+
+ - name: Start pod with changed add host
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ add_host:
+ - "google:8.8.8.8"
+ - "site1:127.0.0.2"
+ dns:
+ - 1.1.1.1
+ - 2.2.2.2
+ dns_opt:
+ - "option timeout:3"
+ dns_search:
+ - "redhat.com"
+ - "ibm.com"
+ hostname: happypod
+ register: pod23_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod23_info is changed
+
+ - name: Start pod with changed dns option
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ add_host:
+ - "google:8.8.8.8"
+ - "site1:127.0.0.2"
+ dns:
+ - 1.1.1.1
+ - 2.2.2.2
+ dns_opt:
+ - "option timeout:2"
+ dns_search:
+ - "redhat.com"
+ - "ibm.com"
+ hostname: happypod
+ register: pod24_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod24_info is changed
+
+ - name: Start pod with changed dns search
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ add_host:
+ - "google:8.8.8.8"
+ - "site1:127.0.0.2"
+ dns:
+ - 1.1.1.1
+ - 2.2.2.2
+ dns_opt:
+ - "option timeout:2"
+ dns_search:
+ - "redhat.com"
+ hostname: happypod
+ register: pod25_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod25_info is changed
+
+ - name: Start pod with changed hostname
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ add_host:
+ - "google:8.8.8.8"
+ - "site1:127.0.0.2"
+ dns:
+ - 1.1.1.1
+ - 2.2.2.2
+ dns_opt:
+ - "option timeout:2"
+ dns_search:
+ - "redhat.com"
+ hostname: bestpod
+ register: pod26_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod26_info is changed
+
+ - name: Start pod with removed dns search
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ add_host:
+ - "google:8.8.8.8"
+ - "site1:127.0.0.2"
+ dns:
+ - 1.1.1.1
+ - 2.2.2.2
+ dns_opt:
+ - "option timeout:2"
+ hostname: bestpod
+ register: pod27_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod27_info is changed
+
+ - name: Start pod with removed dns option
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ add_host:
+ - "google:8.8.8.8"
+ - "site1:127.0.0.2"
+ dns:
+ - 1.1.1.1
+ - 2.2.2.2
+ hostname: bestpod
+ register: pod28_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod28_info is changed
+
+ - name: Start pod with removed dns
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ add_host:
+ - "google:8.8.8.8"
+ - "site1:127.0.0.2"
+ hostname: bestpod
+ register: pod29_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod29_info is changed
+
+ - name: Start pod with removed add host
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ hostname: bestpod
+ register: pod30_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod30_info is changed
+
+ - name: Start pod without infra
+ containers.podman.podman_pod:
+ name: pod1
+ state: created
+ infra: false
+ register: pod31_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod31_info is changed
+
+ - name: Start pod without infra again
+ containers.podman.podman_pod:
+ name: pod1
+ state: created
+ infra: false
+ register: pod32_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod32_info is not changed
+
+ - name: Start pod with infra
+ containers.podman.podman_pod:
+ name: pod1
+ state: started
+ register: pod33_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod33_info is changed
+
+ - name: Start pod with different infra image
+ containers.podman.podman_pod:
+ name: pod1
+ state: created
+ infra_image: alpine:3.9
+ register: pod34_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod34_info is changed
+
+ - name: Start pod with different infra image again
+ containers.podman.podman_pod:
+ name: pod1
+ state: created
+ infra_image: alpine:3.9
+ register: pod35_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod35_info is not changed
+
+ always:
+
+ - name: Delete all pods leftovers from tests
+ containers.podman.podman_pod:
+ name: "{{ item }}"
+ state: absent
+ loop:
+ - "pod1"
+ - "pod2"
+
+- name: Test idempotency for root pods
+ include_tasks: root-pod.yml
+ vars:
+ ansible_python_interpreter: "/usr/bin/python"
+ args:
+ apply:
+ become: true
+
+- name: Test idempotency for root pods and networks
+ include_tasks: net-pod.yml
+ vars:
+ ansible_python_interpreter: "/usr/bin/python"
+ args:
+ apply:
+ become: true
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/net-pod.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/net-pod.yml
new file mode 100644
index 00000000..b1b15def
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/net-pod.yml
@@ -0,0 +1,48 @@
+- name: Test podman rootful pod
+ block:
+
+ - name: Remove pods
+ containers.podman.podman_pod:
+ name: "rootnetpod"
+ state: absent
+
+ - name: Create network testnet
+ command: podman network create testnet --subnet 10.91.91.0/24
+
+ - name: Create network anothernet
+ command: podman network create anothernet --subnet 10.71.71.0/24
+
+ - name: List current networks
+ command: podman network ls
+
+ - name: Set test data
+ set_fact:
+ testdata:
+ - first_net: host
+ next_net: bridge
+ - first_net: bridge
+ next_net: host
+ - first_net: anothernet
+ next_net: testnet
+ - first_net: testnet
+ next_net: testnet,anothernet
+ - first_net: testnet,anothernet
+ next_net: anothernet
+ - first_net: testnet,anothernet
+ next_net: bridge
+ - first_net: testnet,anothernet
+ next_net: host
+ - first_net: host
+ next_net: anothernet
+ - first_net: bridge
+ next_net: anothernet,testnet
+
+ - include_tasks: network-tests.yml
+ loop: "{{ testdata }}"
+
+ always:
+
+ - name: Delete all pods leftovers from tests
+ containers.podman.podman_pod:
+ name: "rootnetpod"
+ state: absent
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/network-tests.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/network-tests.yml
new file mode 100644
index 00000000..8df7016b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/network-tests.yml
@@ -0,0 +1,39 @@
+---
+- name: Remove pod nettest
+ become: true
+ containers.podman.podman_pod:
+ name: nettest
+ state: absent
+
+- name: Run pod with {{ item.first_net }}
+ become: true
+ containers.podman.podman_pod:
+ name: nettest
+ state: started
+ network: "{{ item.first_net }}"
+
+- name: Run pod again with {{ item.first_net }}
+ become: true
+ containers.podman.podman_pod:
+ name: nettest
+ state: started
+ network: "{{ item.first_net }}"
+ register: info
+
+- name: Check info that not changed
+ assert:
+ that:
+ - info is not changed
+
+- name: Run pod changed from {{ item.first_net }} to {{ item.next_net }}
+ become: true
+ containers.podman.podman_pod:
+ name: nettest
+ state: started
+ network: "{{ item.next_net }}"
+ register: info1
+
+- name: Check info
+ assert:
+ that:
+ - info1 is changed
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/root-pod.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/root-pod.yml
new file mode 100644
index 00000000..d0027417
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/root-pod.yml
@@ -0,0 +1,120 @@
+- name: Test podman rootful pod
+ block:
+
+ - name: Discover cgroups version
+ shell: podman info | grep cgroupVersion | awk {'print $2'}
+ register: cgroups
+
+ - name: Set cgroups version
+ set_fact:
+ cgroups_version: "{{ cgroups.stdout }}"
+
+ - name: Delete all pods leftovers from tests
+ containers.podman.podman_pod:
+ name: "rootpod"
+ state: absent
+
+ - name: Create and start pod
+ containers.podman.podman_pod:
+ name: "rootpod"
+ state: started
+
+ - name: Create and start pod
+ containers.podman.podman_pod:
+ name: "rootpod"
+ state: started
+ register: pod1_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod1_info is not changed
+
+ - name: Add DNS to pod
+ containers.podman.podman_pod:
+ name: "rootpod"
+ state: started
+ dns:
+ - 1.1.1.1
+ register: pod2_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod2_info is changed
+
+ - name: Remove DNS from pod
+ containers.podman.podman_pod:
+ name: "rootpod"
+ state: started
+ register: pod3_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod3_info is changed
+
+ - name: Create network newnet
+ command: podman network create newnet --subnet 10.90.90.0/24
+
+ - name: Create network net2
+ command: podman network create net2 --subnet 10.70.70.0/24
+
+ - name: Start pod with networks
+ containers.podman.podman_pod:
+ name: "rootpod"
+ state: started
+ network: net2,newnet
+ register: pod4_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod4_info is changed
+
+ - name: Start pod with networks again
+ containers.podman.podman_pod:
+ name: "rootpod"
+ state: started
+ network: newnet,net2
+ register: pod5_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod5_info is not changed
+
+ - name: Start pod with one network
+ containers.podman.podman_pod:
+ name: "rootpod"
+ state: started
+ network: net2
+ register: pod6_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod6_info is changed
+
+ - name: Start pod without networks
+ containers.podman.podman_pod:
+ name: "rootpod"
+ state: started
+ register: pod7_info
+
+ - name: Check info
+ assert:
+ that:
+ - pod7_info is changed
+
+ always:
+
+ - name: Delete all pods leftovers from tests
+ containers.podman.podman_pod:
+ name: "rootpod"
+ state: absent
+
+ - name: Delete all existing pods
+ shell: |
+ podman pod rm -fa;
+ ignore_errors: true
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod_info/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod_info/tasks/main.yml
new file mode 100644
index 00000000..ccf20bf2
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_pod_info/tasks/main.yml
@@ -0,0 +1,103 @@
+- name: Test podman_pod_info
+ block:
+
+ - name: Print podman version
+ command: podman info --debug
+
+ - name: Discover podman version
+ shell: podman version | grep "^Version:" | awk {'print $2'}
+ register: podman_version
+
+ - name: Generate random value for pod name
+ set_fact:
+ pod_name: "{{ 'ansible-test-podman-%0x' % ((2**32) | random) }}"
+
+ - name: Make sure pod doesn't exist
+ containers.podman.podman_pod:
+ name: "{{ pod_name }}"
+ state: absent
+
+ - name: Get missing pod info
+ containers.podman.podman_pod_info:
+ name: "{{ pod_name }}"
+ register: nonexist
+
+ - name: Check info for missing pod
+ assert:
+ that:
+ - nonexist.pods == []
+
+ - name: Get all missing pods info
+ containers.podman.podman_pod_info:
+ register: nonexist2
+
+ - name: Check info for missing pod
+ assert:
+ that:
+ - nonexist2.pods == []
+
+ - name: Create test pod
+ containers.podman.podman_pod:
+ name: "{{ pod_name }}"
+
+ - name: Get all pods info
+ containers.podman.podman_pod_info:
+ register: info
+
+ - name: Check info for pod
+ assert:
+ that:
+ - info.pods | length == 1
+ - >-
+ (info.pods[0]['Config']['name'] is defined and
+ info.pods[0]['Config']['name'] == pod_name) or
+ (info.pods[0]['Name'] is defined and
+ info.pods[0]['Name'] == pod_name)
+
+ - name: Get specific pod info
+ containers.podman.podman_pod_info:
+ name: "{{ pod_name }}"
+ register: info2
+
+ - name: Check info for pod
+ assert:
+ that:
+ - info2.pods | length == 1
+ - >-
+ (info2.pods[0]['Config']['name'] is defined and
+ info2.pods[0]['Config']['name'] == pod_name) or
+ (info2.pods[0]['Name'] is defined and
+ info2.pods[0]['Name'] == pod_name)
+
+ - name: Create another test pod
+ containers.podman.podman_pod:
+ name: "{{ pod_name }}_1"
+
+ - name: Get specific another pod info
+ containers.podman.podman_pod_info:
+ name: "{{ pod_name }}"
+ register: info3
+
+ - name: Check info for missing pod
+ assert:
+ that:
+ - info3.pods | length == 1
+
+ - name: Get pods info
+ containers.podman.podman_pod_info:
+ register: info4
+
+ - name: Check info for pods
+ assert:
+ that:
+ - info4.pods | length == 2
+
+ always:
+
+ - name: Make sure pod doesn't exist
+ containers.podman.podman_pod:
+ name: "{{ item }}"
+ state: absent
+ loop:
+ - "{{ pod_name }}"
+ - "{{ pod_name }}_1"
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml
new file mode 100644
index 00000000..669b34c5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml
@@ -0,0 +1,267 @@
+- name: Test podman_volume
+ block:
+
+ - name: Print podman version
+ command: podman version
+
+ - name: Generate random value for volume name
+ set_fact:
+ volume_name: "{{ 'ansible-test-podman-%0x' % ((2**32) | random) }}"
+
+ - name: Make sure volume doesn't exist
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: absent
+
+ - name: Get missing volume info
+ containers.podman.podman_volume_info:
+ name: "{{ volume_name }}"
+ register: info
+ ignore_errors: true
+
+ - name: Check results
+ assert:
+ that:
+ - info is failed
+
+ - name: Create volume
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ register: vol
+
+ - name: Get existing volume info
+ containers.podman.podman_volume_info:
+ name: "{{ volume_name }}"
+ register: info1
+
+ - name: Check info
+ assert:
+ that:
+ - info1 | length > 1
+ - info1.volumes.0.Name == volume_name
+ - vol is changed
+
+ - name: Create volume again
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ register: info2
+
+ - name: Check info
+ assert:
+ that:
+ - info2 is not changed
+
+ - name: Create volume with labels
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ label:
+ key: val
+ nokey: noval
+ register: info3
+
+ - name: Check info
+ assert:
+ that:
+ - info3 is changed
+
+ - name: Create volume with labels again
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ label:
+ key: val
+ nokey: noval
+ register: info4
+
+ - name: Check info
+ assert:
+ that:
+ - info4 is not changed
+
+ - name: Create volume w/o labels
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ register: info5
+
+ - name: Check info
+ assert:
+ that:
+ - info5 is changed
+
+ - name: Create volume with options
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ options:
+ - "device=/dev/something"
+ - "type=ext4"
+ register: info6
+
+ - name: Check info
+ assert:
+ that:
+ - info6 is changed
+
+ - name: Create volume with options again
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ options:
+ - "device=/dev/something"
+ - "type=ext4"
+ register: info7
+
+ - name: Check info
+ assert:
+ that:
+ - info7 is not changed
+
+ - name: Create volume w/o options
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ register: info8
+
+ - name: Check info
+ assert:
+ that:
+ - info8 is changed
+
+ - name: Make sure volume doesn't exist
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: absent
+ register: delete
+
+ - name: Get existing volume info
+ containers.podman.podman_volume_info:
+ name: "{{ volume_name }}"
+ register: info10
+ ignore_errors: true
+
+ - name: Check results
+ assert:
+ that:
+ - info10 is failed
+ - delete.volume == {}
+
+ - name: Create volume with UID option
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ options:
+ - "o=uid=1001"
+ register: info11
+
+ - name: Check info
+ assert:
+ that:
+ - info11 is changed
+
+ - name: Create volume with UID option - again
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ options:
+ - "o=uid=1001"
+ register: info12
+
+ - name: Check info
+ assert:
+ that:
+ - info12 is not changed
+
+ - name: Create volume with UID option - default
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ register: info13
+
+ - name: Check info
+ assert:
+ that:
+ - info13 is changed
+
+ - name: Create volume with GID option
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ options:
+ - "o=gid=1001"
+ register: info14
+
+ - name: Check info
+ assert:
+ that:
+ - info14 is changed
+
+ - name: Create volume with GID option - again
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ options:
+ - "o=gid=1001"
+ register: info15
+
+ - name: Check info
+ assert:
+ that:
+ - info15 is not changed
+
+ - name: Create volume with GID option - default
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ register: info16
+
+ - name: Check info
+ assert:
+ that:
+ - info16 is changed
+
+ - name: Create volume with GID and UID option
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ options:
+ - "o=gid=1002,uid=1002"
+ register: info17
+
+ - name: Check info
+ assert:
+ that:
+ - info17 is changed
+
+ - name: Create volume with GID and UID option - again
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ options:
+ - "o=uid=1002"
+ - "o=gid=1002"
+ register: info18
+
+ - name: Check info
+ assert:
+ that:
+ - info18 is not changed
+
+ - name: Create volume with GID and UID option - default
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+ register: info19
+
+ - name: Check info
+ assert:
+ that:
+ - info19 is changed
+ always:
+
+ - name: Make sure volume doesn't exist
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: absent
diff --git a/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_volume_info/tasks/main.yml b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_volume_info/tasks/main.yml
new file mode 100644
index 00000000..9bd046d7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/containers/podman/tests/integration/targets/podman_volume_info/tasks/main.yml
@@ -0,0 +1,65 @@
+- name: Test podman_volume_info
+ block:
+
+ - name: Print podman version
+ command: podman version
+
+ - name: Generate random value for volume name
+ set_fact:
+ volume_name: "{{ 'ansible-test-podman-%0x' % ((2**32) | random) }}"
+
+ - name: Make sure volume doesn't exist
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: absent
+
+ - name: Get missing volume info
+ containers.podman.podman_volume_info:
+ name: "{{ volume_name }}"
+ register: nonexist
+ ignore_errors: true
+
+ - name: Check results
+ assert:
+ that:
+ - "'volumes' not in nonexist"
+ - nonexist is failed
+
+ - name: Make sure volume exists
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: present
+
+ - name: Get existing volume info
+ containers.podman.podman_volume_info:
+ name: "{{ volume_name }}"
+ register: existing_volume
+
+ - name: Dump podman volume inspect result
+ debug: var=existing_volume
+
+ - name: Comparison with 'podman volume inspect'
+ command: podman volume inspect "{{ volume_name }}"
+ register: podman_inspect
+
+ - name: Convert podman inspect output to JSON
+ set_fact:
+ podman_inspect_result: "{{ podman_inspect.stdout | from_json }}"
+
+ - name: Cleanup
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: absent
+
+ - name: Make checks
+ assert:
+ that:
+ - "'volumes' in existing_volume"
+ - existing_volume.volumes
+ - "existing_volume.volumes == podman_inspect_result"
+ always:
+
+ - name: Cleanup
+ containers.podman.podman_volume:
+ name: "{{ volume_name }}"
+ state: absent