summaryrefslogtreecommitdiffstats
path: root/ansible_collections/containers/podman/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 04:05:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-26 04:05:56 +0000
commit67c6a4d1dccb62159b9d9b2dea4e2f487446e276 (patch)
tree9ccbb35137f480bbbdb899accbda52a8135d3416 /ansible_collections/containers/podman/tests
parentAdding upstream version 9.4.0+dfsg. (diff)
downloadansible-67c6a4d1dccb62159b9d9b2dea4e2f487446e276.tar.xz
ansible-67c6a4d1dccb62159b9d9b2dea4e2f487446e276.zip
Adding upstream version 9.5.1+dfsg.upstream/9.5.1+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/containers/podman/tests')
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_container/tasks/main.yml277
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_container_exec/tasks/main.yml20
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml20
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml139
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_generate_systemd/tasks/main.yml11
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml128
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml125
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/files/multi-yaml.yml27
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/main.yml184
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-multi-yaml.yml40
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-with-build.yml3
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-with-options.yml4
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml332
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/resource-limit.yml3
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_prune/tasks/main.yml16
-rw-r--r--ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml128
-rw-r--r--ansible_collections/containers/podman/tests/sanity/ignore-2.10.txt1
-rw-r--r--ansible_collections/containers/podman/tests/sanity/ignore-2.11.txt1
-rw-r--r--ansible_collections/containers/podman/tests/sanity/ignore-2.12.txt1
-rw-r--r--ansible_collections/containers/podman/tests/sanity/ignore-2.13.txt1
-rw-r--r--ansible_collections/containers/podman/tests/sanity/ignore-2.14.txt1
-rw-r--r--ansible_collections/containers/podman/tests/sanity/ignore-2.15.txt1
-rw-r--r--ansible_collections/containers/podman/tests/sanity/ignore-2.16.txt1
-rw-r--r--ansible_collections/containers/podman/tests/sanity/ignore-2.17.txt1
-rw-r--r--ansible_collections/containers/podman/tests/sanity/ignore-2.18.txt1
-rw-r--r--ansible_collections/containers/podman/tests/sanity/ignore-2.9.txt1
26 files changed, 1372 insertions, 95 deletions
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container/tasks/main.yml
index a6fd44083..02d664afa 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_container/tasks/main.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container/tasks/main.yml
@@ -15,6 +15,11 @@
podman_version: 4
when: podman_v.stdout is version('4.0.0', '>=')
+ - name: Set podman version to 5
+ set_fact:
+ podman_version: 5
+ when: podman_v.stdout is version('5.0.0', '>=')
+
- name: Delete all container leftovers from tests
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
@@ -702,7 +707,7 @@
path: /tmp/containzzzzcontainer1.service
register: service_file
- - name: Check that container has correct systemd output v4
+ - name: Check that container has correct systemd output v4 and quadlet
assert:
that:
- system14.podman_systemd.keys() | list | first == 'containzzzzcontainer1'
@@ -712,6 +717,11 @@
- "'autogenerated by Podman' not in system14.podman_systemd.values() | list | first"
- "'RestartSec=10' in system14.podman_systemd.values() | list | first"
- "'TimeoutStartSec=20' in system14.podman_systemd.values() | list | first"
+ - system14.podman_quadlet | length > 0
+ - system14.podman_quadlet | length > 0
+ - "'ContainerName=container1' in system14.podman_quadlet"
+ - "'Image=alpine' in system14.podman_quadlet"
+
when: podman_version == 4
- name: Check that container has correct systemd output v3
@@ -855,9 +865,14 @@
dest: "{{ container_tempdir.path }}/latest-releases.yaml"
register: alpine_releases_file
+ - name: Get content of alpine releases file
+ ansible.builtin.slurp:
+ src: "{{ container_tempdir.path }}/latest-releases.yaml"
+ register: latest_releases_file
+
- name: Download alpine latest rootfs
vars:
- latest_releases: "{{ lookup('file', alpine_releases_file.dest) }}"
+ latest_releases: "{{ latest_releases_file.content | b64decode }}"
latest_version: "{{ (latest_releases | from_yaml)[0].version }}"
latest_branch: "{{ (latest_releases | from_yaml)[0].branch }}"
ansible.builtin.unarchive:
@@ -1075,6 +1090,264 @@
- attach3 is failed
- "'No such file or directory' in attach3.stderr"
+ - name: Create a Quadlet for container with filename
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: container-quadlet
+ image: alpine
+ state: quadlet
+ quadlet_dir: /tmp
+ quadlet_filename: customfile
+
+ - name: Check if files exists
+ stat:
+ path: /tmp/customfile.container
+ register: quadlet_file_custom
+
+ - name: Fail if no file is present
+ assert:
+ that:
+ - quadlet_file_custom.stat.exists
+
+ - name: Create a Quadlet for container with filename w/o dir
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: container-quadlet
+ image: alpine
+ state: quadlet
+ quadlet_filename: container11.container
+
+ - name: Check if files exists
+ stat:
+ path: ~/.config/containers/systemd/container11.container
+ register: quadlet_file_custom2
+
+ - name: Fail if no file is present
+ assert:
+ that:
+ - quadlet_file_custom2.stat.exists
+
+ - name: Create a Quadlet for container with filename w/o dir
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: container-quadlet
+ image: alpine
+ state: quadlet
+
+ - name: Check if files exists
+ stat:
+ path: ~/.config/containers/systemd/container-quadlet.container
+ register: quadlet_file_custom3
+
+ - name: Fail if no file is present
+ assert:
+ that:
+ - quadlet_file_custom3.stat.exists
+
+ - name: Create a Quadlet for container
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: container-quadlet
+ image: alpine:3.12
+ state: quadlet
+ quadlet_dir: /tmp
+ 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
+ mounts:
+ - type=devpts,destination=/dev/pts
+ quadlet_options:
+ - AutoUpdate=registry
+ - Unmask=ALL
+ - SecurityLabelFileType=usr_t
+ - Annotation=key1=annotation_value1
+ - Annotation=key2=annotation_value2
+ - |
+ [Install]
+ WantedBy=default.target
+
+ - name: Check if files exists
+ stat:
+ path: /tmp/container-quadlet.container
+ register: quadlet_file
+
+ - name: Check output is correct for Quadlet container in /tmp/container-quadlet.container file
+ assert:
+ that:
+ - quadlet_file.stat.exists
+
+ - name: Check for the existence of lines in /tmp/container-quadlet.container
+ lineinfile:
+ path: /tmp/container-quadlet.container
+ line: "{{ item }}"
+ state: present
+ check_mode: yes
+ register: line_check
+ loop:
+ - "[Container]"
+ - "Annotation=this=annotation_value"
+ - "Annotation=key1=annotation_value1"
+ - "Annotation=key2=annotation_value2"
+ - "ContainerName=container-quadlet"
+ - "Image=alpine:3.12"
+ - "Exec=sleep 1d"
+ - "Volume=/tmp:/data"
+ - "Mount=type=devpts,destination=/dev/pts"
+ - "WorkingDir=/bin"
+ - "Unmask=ALL"
+ - "SecurityLabelFileType=usr_t"
+ - "Environment=BOOL=False"
+ - "PublishPort=9001:8000"
+ - "PodmanArgs=--add-host host2:127.0.0.1"
+ - "Label=somelabel=labelvalue"
+ - "WantedBy=default.target"
+ loop_control:
+ label: "{{ item }}"
+
+ - name: Fail the task if any line is not present
+ fail:
+ msg: "The following line is not present in /tmp/container-quadlet.container: {{ item.item }}"
+ when: item.changed
+ loop: "{{ line_check.results }}"
+ loop_control:
+ label: "{{ item.item }}"
+
+ - name: Create a Quadlet for container - same
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: container-quadlet
+ image: alpine:3.12
+ state: quadlet
+ quadlet_dir: /tmp
+ 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
+ mounts:
+ - type=devpts,destination=/dev/pts
+ quadlet_options:
+ - AutoUpdate=registry
+ - Unmask=ALL
+ - SecurityLabelFileType=usr_t
+ - Annotation=key1=annotation_value1
+ - Annotation=key2=annotation_value2
+ - |
+ [Install]
+ WantedBy=default.target
+ register: quad2
+
+ - name: Check if quadlet changed
+ assert:
+ that:
+ - quad2 is not changed
+
+ - name: Create a Quadlet for container - different
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: container-quadlet
+ image: alpine:3.12
+ state: quadlet
+ quadlet_dir: /tmp
+ command: sleep 1d
+ recreate: true
+ etc_hosts:
+ host1: 127.0.0.45
+ 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
+ mounts:
+ - type=devpts,destination=/dev/pts
+ quadlet_options:
+ - AutoUpdate=registry
+ - Unmask=ALL
+ - SecurityLabelFileType=usr_t
+ - Annotation=key1=annotation_value1
+ - Annotation=key2=annotation_value2
+ - |
+ [Install]
+ WantedBy=default.target
+ register: quad3
+
+ - name: Print diff
+ debug:
+ var: quad3.diff
+
+ - name: Check if changed and diff
+ assert:
+ that:
+ - quad3 is changed
+ - "'127.0.0.45' in quad3.diff.after"
+
always:
- name: Remove container
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_exec/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_exec/tasks/main.yml
index 2d2874325..623965c10 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_container_exec/tasks/main.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_exec/tasks/main.yml
@@ -12,6 +12,7 @@
- name: Test exec when the container doesn't exist
containers.podman.podman_container_exec:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ container_name }}"
command: "cat /etc/redhat-release"
ignore_errors: true
@@ -19,6 +20,7 @@
- name: Create and start a container for testing
containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ container_name }}"
image: registry.access.redhat.com/ubi8
command: sleep 1d
@@ -26,6 +28,7 @@
- name: Test exec with command and workdir options
containers.podman.podman_container_exec:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ container_name }}"
command: "cat redhat-release"
workdir: /etc
@@ -33,6 +36,7 @@
- name: Test exec with argv and env options
containers.podman.podman_container_exec:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ container_name }}"
argv:
- /bin/sh
@@ -45,6 +49,7 @@
- name: Test exec with detach option
containers.podman.podman_container_exec:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ container_name }}"
command: "cat redhat-release"
detach: true
@@ -59,6 +64,21 @@
- "'goodbye world' in exec2.stdout"
- exec3.exec_id is defined
+ - name: Test exec with failing command
+ containers.podman.podman_container_exec:
+ executable: "{{ test_executable | default('podman') }}"
+ name: "{{ container_name }}"
+ command: "ls /nonexistent"
+ register: exec4
+ ignore_errors: true
+
+ - name: Check if the result is as expected in case of a failing command
+ assert:
+ that:
+ - exec4 is failed
+ - "'No such file or directory' in exec4.stderr"
+ - exec4.rc != 0
+
always:
- name: Cleanup
containers.podman.podman_container:
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml
index 3d3654aea..02b66d250 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/main.yml
@@ -1,4 +1,24 @@
---
+
+- name: Discover podman version
+ shell: podman version | grep "^Version:" | awk {'print $2'}
+ register: podman_v
+
+- name: Set podman version to 3
+ set_fact:
+ podman_version: 3
+ when: podman_v.stdout is version('4.0.0', 'lt')
+
+- name: Set podman version to 4
+ set_fact:
+ podman_version: 4
+ when: podman_v.stdout is version('4.0.0', '>=')
+
+- name: Set podman version to 5
+ set_fact:
+ podman_version: 5
+ when: podman_v.stdout is version('5.0.0', '>=')
+
- name: Prepare a container
include_tasks: build_test_container.yml
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml
index 62dd3a5a0..3c16efac2 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_container_idempotency/tasks/rootless-podman-network.yml
@@ -109,53 +109,108 @@
that:
- info5 is changed
- - name: Run container with slirp4netns options
- containers.podman.podman_container:
- executable: "{{ test_executable | default('podman') }}"
- name: rootlessnet
- image: "{{ idem_image }}"
- command: 1h
- state: present
- network:
- - slirp4netns:allow_host_loopback=true,cidr=10.0.3.0/24
- register: info6
+ - when: podman_version < 5
+ name: Run container tasks with slirp4netns options before v5
+ block:
+ - name: Run container with slirp4netns options
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network:
+ - slirp4netns:allow_host_loopback=true,cidr=10.0.3.0/24
+ register: info6
- - name: Check info with slirp4netns options
- assert:
- that:
- - info6 is changed
+ - name: Check info with slirp4netns options
+ assert:
+ that:
+ - info6 is changed
- - name: Run container with slirp4netns options - again
- containers.podman.podman_container:
- executable: "{{ test_executable | default('podman') }}"
- name: rootlessnet
- image: "{{ idem_image }}"
- command: 1h
- state: present
- network:
- - slirp4netns:allow_host_loopback=true,cidr=10.0.3.0/24
- register: info7
+ - name: Run container with slirp4netns options - again
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network:
+ - slirp4netns:allow_host_loopback=true,cidr=10.0.3.0/24
+ register: info7
- - name: Check info with slirp4netns options - again
- assert:
- that:
- - info7 is not changed
+ - name: Check info with slirp4netns options - again
+ assert:
+ that:
+ - info7 is not changed
- - name: Run container with different slirp4netns options
- containers.podman.podman_container:
- executable: "{{ test_executable | default('podman') }}"
- name: rootlessnet
- image: "{{ idem_image }}"
- command: 1h
- state: present
- network:
- - slirp4netns:allow_host_loopback=true,cidr=10.0.4.0/24
- register: info8
+ - name: Run container with different slirp4netns options
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network:
+ - slirp4netns:allow_host_loopback=true,cidr=10.0.4.0/24
+ register: info8
- - name: Check info with different slirp4netns options
- assert:
- that:
- - info8 is changed
+ - name: Check info with different slirp4netns options
+ assert:
+ that:
+ - info8 is changed
+
+
+ - when: podman_version >= 5
+ name: Run container tasks with pasta options for v5 and later
+ block:
+ - name: Run container with pasta options
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network:
+ - "pasta:-4,-t,8007,-u,4443,-T,3000"
+ register: info6
+
+ - name: Check info with pasta options
+ assert:
+ that:
+ - info6 is changed
+
+ - name: Run container with pasta options - again
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network:
+ - "pasta:-4,-t,8007,-u,4443,-T,3000"
+ register: info7
+
+ - name: Check info with pasta options - again
+ assert:
+ that:
+ - info7 is not changed
+
+ - name: Run container with different pasta options
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: rootlessnet
+ image: "{{ idem_image }}"
+ command: 1h
+ state: present
+ network:
+ - "pasta:-4,-t,8008,-u,4443,-T,3000"
+ register: info8
+
+ - name: Check info with different pasta options
+ assert:
+ that:
+ - info8 is changed
- name: Run container without options
containers.podman.podman_container:
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_generate_systemd/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_generate_systemd/tasks/main.yml
index 1e48a11dc..6b0c335cd 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_generate_systemd/tasks/main.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_generate_systemd/tasks/main.yml
@@ -1,11 +1,14 @@
- name: A postgres container must exist, stopped
containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
name: postgres_local
image: docker.io/library/postgres:latest
+ # image: quay.io/enterprisedb/postgresql - use if docker is rate limited
state: stopped
- name: Generate the systemd units as Ansible variables
containers.podman.podman_generate_systemd:
+ executable: "{{ test_executable | default('podman') }}"
name: postgres_local
register: postgres_local_systemd_unit
ignore_errors: true
@@ -29,6 +32,7 @@
- name: Regenerate the systemd units and write them
containers.podman.podman_generate_systemd:
+ executable: "{{ test_executable | default('podman') }}"
name: postgres_local
dest: /tmp/podman_generate_systemd
register: postgres_local_systemd_unit
@@ -41,6 +45,7 @@
- name: Try to create a systemd unit file on the same path
containers.podman.podman_generate_systemd:
+ executable: "{{ test_executable | default('podman') }}"
name: postgres_local
dest: /tmp/podman_generate_systemd
register: generate1
@@ -58,6 +63,7 @@
- name: Force to create a systemd unit file on the same path
containers.podman.podman_generate_systemd:
+ executable: "{{ test_executable | default('podman') }}"
name: postgres_local
dest: /tmp/podman_generate_systemd
force: true
@@ -83,6 +89,7 @@
- name: Regenerate the systemd units with all the options
containers.podman.podman_generate_systemd:
+ executable: "{{ test_executable | default('podman') }}"
name: postgres_local
new: true
restart_policy: on-abnormal
@@ -100,7 +107,6 @@
after: drink.service
wants: water.service
requires: ice.service
- executable: /usr/bin/podman
register: postgres_local_systemd_unit
ignore_errors: true
@@ -123,13 +129,14 @@
- postgres_local_systemd_unit.podman_command is search("--after=drink.service")
- postgres_local_systemd_unit.podman_command is search("--wants=water.service")
- postgres_local_systemd_unit.podman_command is search("--requires=ice.service")
- - postgres_local_systemd_unit.podman_command is search("/usr/bin/podman")
+ - postgres_local_systemd_unit.podman_command is search("podman")
- name: Remove container
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: postgres_local
state: absent
+
- name: Remove the systemd unit files directory
ansible.builtin.file:
path: /tmp/podman_generate_systemd
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml
index 0db4c050c..96133b9da 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_image/tasks/main.yml
@@ -329,6 +329,134 @@
- item.Architecture == "arm"
loop: "{{ imageinfo_arch.images }}"
+ - name: Create a Quadlet for image with filename
+ containers.podman.podman_image:
+ executable: "{{ test_executable | default('podman') }}"
+ name: quay.io/coreos/coreos-installer:latest
+ state: quadlet
+ arch: x86_64
+ quadlet_dir: /tmp
+ quadlet_filename: customfile
+
+ - name: Check if files exists
+ stat:
+ path: /tmp/customfile.image
+ register: quadlet_file_custom
+
+ - name: Fail if no file is present
+ assert:
+ that:
+ - quadlet_file_custom.stat.exists
+
+ - name: Create quadlet image file
+ containers.podman.podman_image:
+ executable: "{{ test_executable | default('podman') }}"
+ name: quay.io/coreos/coreos-installer:latest
+ state: quadlet
+ arch: x86_64
+ ca_cert_dir: /etc/docker/certs.d
+ username: user
+ password: pass
+ validate_certs: false
+ quadlet_dir: /tmp/
+ quadlet_options:
+ - "ImageTag=quay.io/coreos/coreos-installer:12345"
+ - "AllTags=true"
+ - |-
+ [Install]
+ WantedBy=default.target
+
+ - name: Check if files exists
+ stat:
+ path: /tmp/coreos-installer.image
+ register: quadlet_file
+
+ - name: Check output is correct for Quadlet image in /tmp/coreos-installer.image file
+ assert:
+ that:
+ - quadlet_file.stat.exists
+
+ - name: Check for the existence of lines in /tmp/coreos-installer.image
+ lineinfile:
+ path: /tmp/coreos-installer.image
+ line: "{{ item }}"
+ state: present
+ check_mode: yes
+ register: line_check
+ loop:
+ - "[Image]"
+ - "Image=quay.io/coreos/coreos-installer:latest"
+ - "ImageTag=quay.io/coreos/coreos-installer:12345"
+ - "AllTags=true"
+ - "WantedBy=default.target"
+ - "Arch=x86_64"
+ - "CertDir=/etc/docker/certs.d"
+ - "Creds=user:pass"
+ - "TLSVerify=false"
+ loop_control:
+ label: "{{ item }}"
+
+ - name: Fail the task if any line is not present
+ fail:
+ msg: "The following line is not present in /tmp/coreos-installer.image: {{ item.item }}"
+ when: item.changed
+ loop: "{{ line_check.results }}"
+ loop_control:
+ label: "{{ item.item }}"
+
+ - name: Create quadlet image file - same
+ containers.podman.podman_image:
+ executable: "{{ test_executable | default('podman') }}"
+ name: quay.io/coreos/coreos-installer:latest
+ state: quadlet
+ arch: x86_64
+ ca_cert_dir: /etc/docker/certs.d
+ username: user
+ password: pass
+ validate_certs: false
+ quadlet_dir: /tmp
+ quadlet_options:
+ - "ImageTag=quay.io/coreos/coreos-installer:12345"
+ - "AllTags=true"
+ - |-
+ [Install]
+ WantedBy=default.target
+ register: quad2
+
+ - name: Check if quadlet changed
+ assert:
+ that:
+ - quad2 is not changed
+
+ - name: Create quadlet image file - different
+ containers.podman.podman_image:
+ executable: "{{ test_executable | default('podman') }}"
+ name: quay.io/coreos/coreos-installer:latest
+ state: quadlet
+ arch: arm64
+ ca_cert_dir: /etc/docker/certs.d
+ username: user
+ password: pass
+ validate_certs: false
+ quadlet_dir: /tmp/
+ quadlet_options:
+ - "ImageTag=quay.io/coreos/coreos-installer:12345"
+ - "AllTags=true"
+ - |-
+ [Install]
+ WantedBy=default.target
+ register: quad3
+
+ - name: Print diff
+ debug:
+ var: quad3.diff
+
+ - name: Check if changed and diff
+ assert:
+ that:
+ - quad3 is changed
+ - "'arm64' in quad3.diff.after"
+
always:
- name: Cleanup images
containers.podman.podman_image:
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml
index d207e4cef..272ac6b43 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_network/tasks/main.yml
@@ -350,6 +350,131 @@
that:
- info17 is not changed
+ - name: Create a Quadlet for network with filename
+ containers.podman.podman_network:
+ executable: "{{ test_executable | default('podman') }}"
+ name: testnet
+ state: quadlet
+ quadlet_dir: /tmp
+ quadlet_filename: customfile
+
+ - name: Check if files exists
+ stat:
+ path: /tmp/customfile.network
+ register: quadlet_file_custom
+
+ - name: Fail if no file is present
+ assert:
+ that:
+ - quadlet_file_custom.stat.exists
+
+ - name: Create quadlet network file
+ containers.podman.podman_network:
+ executable: "{{ test_executable | default('podman') }}"
+ name: testnet
+ state: quadlet
+ disable_dns: true
+ subnet: "10.123.12.0"
+ internal: false
+ opt:
+ isolate: true
+ mtu: 1511
+ vlan: 111
+ quadlet_dir: /tmp
+ quadlet_options:
+ - "Label=Test=network"
+ - "Label=foo=bar"
+
+ - name: Check if files exists
+ stat:
+ path: /tmp/testnet.network
+ register: quadlet_file
+
+ - name: Check output is correct for Quadlet network in /tmp/testnet.network file
+ assert:
+ that:
+ - quadlet_file.stat.exists
+
+ - name: Check for the existence of lines in /tmp/testnet.network
+ lineinfile:
+ path: /tmp/testnet.network
+ line: "{{ item }}"
+ state: present
+ check_mode: yes
+ register: line_check
+ loop:
+ - "[Network]"
+ - "NetworkName=testnet"
+ - "Subnet=10.123.12.0"
+ - "DisableDNS=true"
+ - "Internal=false"
+ - "Options=isolate=True"
+ - "Options=mtu=1511"
+ - "Options=vlan=111"
+ - "Label=Test=network"
+ - "Label=foo=bar"
+ loop_control:
+ label: "{{ item }}"
+
+ - name: Fail the task if any line is not present
+ fail:
+ msg: "The following line is not present in /tmp/testnet.network: {{ item.item }}"
+ when: item.changed
+ loop: "{{ line_check.results }}"
+ loop_control:
+ label: "{{ item.item }}"
+
+ - name: Create quadlet network file - same
+ containers.podman.podman_network:
+ executable: "{{ test_executable | default('podman') }}"
+ name: testnet
+ state: quadlet
+ disable_dns: true
+ subnet: "10.123.12.0"
+ internal: false
+ opt:
+ isolate: true
+ mtu: 1511
+ vlan: 111
+ quadlet_dir: /tmp
+ quadlet_options:
+ - "Label=Test=network"
+ - "Label=foo=bar"
+ register: quad2
+
+ - name: Check if quadlet changed
+ assert:
+ that:
+ - quad2 is not changed
+
+ - name: Create quadlet network file - different
+ containers.podman.podman_network:
+ executable: "{{ test_executable | default('podman') }}"
+ name: testnet
+ state: quadlet
+ disable_dns: true
+ subnet: "10.123.15.0"
+ internal: false
+ opt:
+ isolate: true
+ mtu: 1511
+ vlan: 111
+ quadlet_dir: /tmp
+ quadlet_options:
+ - "Label=Test=network"
+ - "Label=foo=bar"
+ register: quad3
+
+ - name: Print diff
+ debug:
+ var: quad3.diff
+
+ - name: Check if changed and diff
+ assert:
+ that:
+ - quad3 is changed
+ - "'10.123.15.0' in quad3.diff.after"
+
always:
- name: Cleanup
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/files/multi-yaml.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/files/multi-yaml.yml
new file mode 100644
index 000000000..2a969556b
--- /dev/null
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/files/multi-yaml.yml
@@ -0,0 +1,27 @@
+kind: ConfigMap
+metadata:
+ name: foo
+data:
+ FOO: bar
+---
+apiVersion: v1
+kind: Pod
+metadata:
+ name: foobar
+spec:
+ containers:
+ - command:
+ - top
+ name: container-1
+ image: alpine
+ envFrom:
+ - configMapRef:
+ name: foo
+ optional: false
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: foo2
+data:
+ FOO2: bar2 \ No newline at end of file
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/main.yml
index ae9d8572b..d22615e45 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/main.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/main.yml
@@ -107,6 +107,180 @@
that:
- info1['pods'][0]['State'] == 'Running'
+ - name: Remove pods created by kube play
+ containers.podman.podman_play:
+ executable: "{{ test_executable | default('podman') }}"
+ kube_file: /tmp/play3.yaml
+ state: absent
+ register: remove_pod
+
+ - name: Check if the pod was removed as expected
+ assert:
+ that:
+ - remove_pod is changed
+
+ - name: Get deleted pod info
+ containers.podman.podman_pod_info:
+ executable: "{{ test_executable | default('podman') }}"
+ name: web-deploy-pod
+ register: nonexist
+
+ - name: Check if the result is as expected
+ assert:
+ that:
+ - nonexist.pods == []
+
+
+ - name: Create a Quadlet for kube with filename
+ containers.podman.podman_play:
+ executable: "{{ test_executable | default('podman') }}"
+ kube_file: /home/kubeuser/tmp/multipod.yaml
+ state: quadlet
+ quadlet_dir: /tmp
+ quadlet_filename: customfile
+
+ - name: Check if files exists
+ stat:
+ path: /tmp/customfile.kube
+ register: quadlet_file_custom
+
+ - name: Fail if no file is present
+ assert:
+ that:
+ - quadlet_file_custom.stat.exists
+
+ - name: Create a kube quadlet without filename
+ containers.podman.podman_play:
+ executable: "{{ test_executable | default('podman') }}"
+ kube_file: /home/kubeuser/tmp/multipod.yaml
+ state: quadlet
+ quadlet_dir: /tmp
+ register: quadlet_file_no_name
+ ignore_errors: true
+
+ - name: Check that task failed
+ assert:
+ that:
+ - quadlet_file_no_name is failed
+
+ - name: Create a kube quadlet
+ containers.podman.podman_play:
+ executable: "{{ test_executable | default('podman') }}"
+ kube_file: /home/kubeuser/tmp/multipod.yaml
+ state: quadlet
+ userns: keep-id:uid=200,gid=210
+ log_driver: journald
+ network: host
+ configmap:
+ - /tmp/configmap1
+ - /tmp/configmap2
+ debug: true
+ quadlet_dir: /tmp
+ quadlet_filename: quadlet
+ quadlet_options:
+ - "PodmanArgs=--annotation=key1=value1"
+ - "PodmanArgs=--context-dir /my/path"
+ - |
+ [Install]
+ WantedBy=default.target
+
+ - name: Check if files exists
+ stat:
+ path: /tmp/quadlet.kube
+ register: quadlet_file
+
+ - name: Check output is correct for Quadlet container in /tmp/quadlet.kube file
+ assert:
+ that:
+ - quadlet_file.stat.exists
+
+ - name: Check for the existence of lines in /tmp/quadlet.kube
+ lineinfile:
+ path: /tmp/quadlet.kube
+ line: "{{ item }}"
+ state: present
+ check_mode: yes
+ register: line_check
+ loop:
+ - "[Kube]"
+ - "ConfigMap=/tmp/configmap1"
+ - "ConfigMap=/tmp/configmap2"
+ - "LogDriver=journald"
+ - "Network=host"
+ - "Yaml=/home/kubeuser/tmp/multipod.yaml"
+ - "UserNS=keep-id:uid=200,gid=210"
+ - "GlobalArgs=--log-level debug"
+ - "WantedBy=default.target"
+ loop_control:
+ label: "{{ item }}"
+
+ - name: Fail the task if any line is not present
+ fail:
+ msg: "The following line is not present in /tmp/quadlet.kube: {{ item.item }}"
+ when: item.changed
+ loop: "{{ line_check.results }}"
+ loop_control:
+ label: "{{ item.item }}"
+
+ - name: Create a kube quadlet - same
+ containers.podman.podman_play:
+ executable: "{{ test_executable | default('podman') }}"
+ kube_file: /home/kubeuser/tmp/multipod.yaml
+ state: quadlet
+ userns: keep-id:uid=200,gid=210
+ log_driver: journald
+ network: host
+ configmap:
+ - /tmp/configmap1
+ - /tmp/configmap2
+ debug: true
+ quadlet_dir: /tmp
+ quadlet_filename: quadlet.kube
+ quadlet_options:
+ - "PodmanArgs=--annotation=key1=value1"
+ - "PodmanArgs=--context-dir /my/path"
+ - |
+ [Install]
+ WantedBy=default.target
+ register: quad2
+
+ - name: Check if quadlet changed
+ assert:
+ that:
+ - quad2 is not changed
+
+ - name: Create a kube quadlet - different
+ containers.podman.podman_play:
+ executable: "{{ test_executable | default('podman') }}"
+ kube_file: /home/kubeuser/tmp/multipod.yaml
+ state: quadlet
+ userns: keep-id:uid=200,gid=210
+ log_driver: journald
+ network: host
+ configmap:
+ - /tmp/configmap55
+ - /tmp/configmap2
+ debug: true
+ quadlet_dir: /tmp
+ quadlet_filename: quadlet.kube
+ quadlet_options:
+ - "PodmanArgs=--annotation=key1=value1"
+ - "PodmanArgs=--context-dir /my/path"
+ - |
+ [Install]
+ WantedBy=default.target
+ register: quad3
+
+ - name: Print diff
+ debug:
+ var: quad3.diff
+
+ - name: Check if changed and diff
+ assert:
+ that:
+ - quad3 is changed
+ - "'configmap55' in quad3.diff.after"
+
always:
- name: Delete all pods leftovers from tests
@@ -145,4 +319,12 @@
size: 10mb
userns: host
kube_dir: /tmp
- kube_file: play-pod.yaml \ No newline at end of file
+ kube_file: play-pod.yaml
+
+- name: Test play kube with multi doc yaml
+ include_tasks: play-multi-yaml.yml
+ vars:
+ ansible_python_interpreter: "/usr/bin/python"
+ kube_dir: /tmp
+ kube_file: multi-yaml.yml
+ target_container: foobar-container-1
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-multi-yaml.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-multi-yaml.yml
new file mode 100644
index 000000000..5eae4f5e5
--- /dev/null
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-multi-yaml.yml
@@ -0,0 +1,40 @@
+---
+- name: Test kube play wih multi doc yaml
+ block:
+ - name: Copy kube file
+ copy:
+ src: "{{ kube_file }}"
+ dest: "{{ kube_dir }}/{{ kube_file }}"
+ remote_src: false
+
+ - name: Create Pod with multi doc yaml
+ containers.podman.podman_play:
+ executable: "{{ test_executable | default('podman') }}"
+ kube_file: "{{ kube_dir }}/{{ kube_file }}"
+ state: started
+ recreate: true
+ register: play_pod
+
+ - name: Get pod info
+ containers.podman.podman_container_info:
+ executable: "{{ test_executable | default('podman') }}"
+ name: "{{ target_container }}"
+ register: info
+
+ - name: Check if an expected container is running
+ assert:
+ that:
+ - info.containers.0.State.Running == true
+ - '"FOO=bar" in info.containers.0.Config.Env'
+
+ - name: Cleanup pod
+ containers.podman.podman_play:
+ executable: "{{ test_executable | default('podman') }}"
+ kube_file: "{{ kube_dir }}/{{ kube_file }}"
+ state: absent
+ register: remove_pod
+
+ - name: Check if the pod was removed as expected
+ assert:
+ that:
+ - remove_pod is changed
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-with-build.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-with-build.yml
index e7601f531..32fde5d6a 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-with-build.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-with-build.yml
@@ -9,6 +9,7 @@
- name: Make sure that {{ image_name }} image is absent
containers.podman.podman_image:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ image_name }}"
state: absent
@@ -31,6 +32,7 @@
- name: Play kube file with image build
containers.podman.podman_play:
+ executable: "{{ test_executable | default('podman') }}"
kube_file: "{{ kube_dir }}/kube-buil-test.yaml"
build: true
context_dir: "{{ build_context_dir }}"
@@ -47,5 +49,6 @@
- name: Cleanup pods
containers.podman.podman_play:
+ executable: "{{ test_executable | default('podman') }}"
kube_file: "{{ kube_dir }}/kube-buil-test.yaml"
state: absent
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-with-options.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-with-options.yml
index aeb79a5bc..40167368b 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-with-options.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_play/tasks/play-with-options.yml
@@ -9,6 +9,7 @@
- name: Create Pod with many options
containers.podman.podman_play:
+ executable: "{{ test_executable | default('podman') }}"
kube_file: "{{ kube_dir }}/{{ kube_file }}"
state: started
recreate: true
@@ -23,6 +24,7 @@
- name: Get pod info
containers.podman.podman_pod_info:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ target_pod }}"
register: play_pod_info
@@ -33,6 +35,7 @@
- name: Get container info
containers.podman.podman_container_info:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ target_container }}"
register: play_container_info
@@ -48,5 +51,6 @@
- name: Cleanup pods
containers.podman.podman_play:
+ executable: "{{ test_executable | default('podman') }}"
kube_file: "{{ kube_dir }}/{{ kube_file }}"
state: absent
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml
index abee17596..cb455aa23 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/main.yml
@@ -15,6 +15,21 @@
podman_version: 2
when: podman_v.stdout is version('2.0.0', '>=')
+ - name: Set podman version to 3
+ set_fact:
+ podman_version: 3
+ when: podman_v.stdout is version('3.0.0', '>=')
+
+ - name: Set podman version to 4
+ set_fact:
+ podman_version: 4
+ when: podman_v.stdout is version('4.0.0', '>=')
+
+ - name: Set podman version to 5
+ set_fact:
+ podman_version: 5
+ when: podman_v.stdout is version('5.0.0', '>=')
+
- name: Discover cgroups version
shell: podman info | grep cgroupVersion | awk {'print $2'}
register: cgroups
@@ -153,6 +168,7 @@
pod6_info.pod['State']['status'] == 'Exited') or
(pod6_info.pod['State']['status'] is not defined and
pod6_info.pod['State'] == 'Exited')
+ when: podman_version < 5
- name: Start pod
containers.podman.podman_pod:
@@ -826,69 +842,289 @@
that:
- not podsys2_stat.stat.exists|bool
- - name: Run pod2 with network slirp4netns
+ - name: Run slirp4netns tests for podman < 5
+ when: podman_version < 5
+ block:
+
+ - name: Run pod2 with network slirp4netns
+ containers.podman.podman_pod:
+ executable: "{{ test_executable | default('podman') }}"
+ name: pod2
+ state: started
+ network: slirp4netns:outbound_addr=10.10.10.46
+
+ - name: Run container1 in pod
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: container1
+ image: alpine
+ command: top
+ pod: pod2
+ state: started
+
+ - name: Run pod2 with network slirp4netns - again
+ containers.podman.podman_pod:
+ executable: "{{ test_executable | default('podman') }}"
+ name: pod2
+ state: started
+ network: slirp4netns:outbound_addr=10.10.10.46
+ register: slip4net_pod
+
+ - name: Run container1 in pod slirp4netns
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: container1
+ image: alpine
+ command: top
+ pod: pod2
+ state: started
+ register: slip4net_cont
+
+ - name: Check that slirp4netns is idempotent
+ assert:
+ that:
+ - slip4net_pod is not changed
+ - slip4net_cont is not changed
+
+ - name: Run pod2 with different network slirp4netns
+ containers.podman.podman_pod:
+ executable: "{{ test_executable | default('podman') }}"
+ name: pod2
+ state: started
+ network: slirp4netns:outbound_addr=10.10.10.47
+ register: slip4net_pod2
+
+ - name: Run container1 in different pod slirp4netns
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: container1
+ image: alpine
+ command: top
+ pod: pod2
+ state: started
+ register: slip4net_cont2
+
+ - name: Check that slirp4netns is idempotent and changed
+ assert:
+ that:
+ - slip4net_pod2 is changed
+ - slip4net_cont2 is changed
+
+ - name: Run pasta tests for podman >= 5
+ when: podman_version >= 5
+ block:
+
+ - name: Run pod2 with network pasta
+ containers.podman.podman_pod:
+ executable: "{{ test_executable | default('podman') }}"
+ name: pod2
+ state: started
+ network:
+ - "pasta:-4,-t,8007,-u,4443,-T,3000"
+
+ - name: Run container1 in pod
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: container1
+ image: alpine
+ command: top
+ pod: pod2
+ state: started
+
+ - name: Run pod2 with network pasta - again
+ containers.podman.podman_pod:
+ executable: "{{ test_executable | default('podman') }}"
+ name: pod2
+ state: started
+ network:
+ - "pasta:-4,-t,8007,-u,4443,-T,3000"
+ register: pasta_pod
+
+ - name: Run container1 in pod pasta
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: container1
+ image: alpine
+ command: top
+ pod: pod2
+ state: started
+ register: pasta_cont
+
+ - name: Check that pasta is idempotent
+ assert:
+ that:
+ - pasta_pod is not changed
+ - pasta_cont is not changed
+
+ - name: Run pod2 with different network pasta
+ containers.podman.podman_pod:
+ executable: "{{ test_executable | default('podman') }}"
+ name: pod2
+ state: started
+ network:
+ - "pasta:-4,-t,8008,-u,4443,-T,3000"
+ register: pasta_pod2
+
+ - name: Run container1 in different pod slirp4netns
+ containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
+ name: container1
+ image: alpine
+ command: top
+ pod: pod2
+ state: started
+ register: pasta_cont2
+
+ - name: Check that slirp4netns is idempotent and changed
+ assert:
+ that:
+ - pasta_pod2 is changed
+ - pasta_cont2 is changed
+
+ - name: Create a Quadlet for pod with filename
containers.podman.podman_pod:
executable: "{{ test_executable | default('podman') }}"
- name: pod2
- state: started
- network: slirp4netns:outbound_addr=10.10.10.46
+ name: podq
+ state: quadlet
+ network: examplenet
+ quadlet_dir: /tmp
+ quadlet_filename: customfile
- - name: Run container1 in pod
- containers.podman.podman_container:
- executable: "{{ test_executable | default('podman') }}"
- name: container1
- image: alpine
- command: top
- pod: pod2
- state: started
+ - name: Check if files exists
+ stat:
+ path: /tmp/customfile.pod
+ register: quadlet_file_custom
- - name: Run pod2 with network slirp4netns - again
- containers.podman.podman_pod:
- executable: "{{ test_executable | default('podman') }}"
- name: pod2
- state: started
- network: slirp4netns:outbound_addr=10.10.10.46
- register: slip4net_pod
+ - name: Fail if no file is present
+ assert:
+ that:
+ - quadlet_file_custom.stat.exists
- - name: Run container1 in pod slirp4netns
- containers.podman.podman_container:
+ - name: Create a Quadlet pod file
+ containers.podman.podman_pod:
executable: "{{ test_executable | default('podman') }}"
- name: container1
- image: alpine
- command: top
- pod: pod2
- state: started
- register: slip4net_cont
+ name: podq
+ state: quadlet
+ network: examplenet
+ share: net
+ subuidname: username1
+ userns: auto
+ publish: 8000:8001
+ add_host:
+ - host1
+ volume:
+ - /tmp:/data
+ - /whocares:/data2:ro
+ quadlet_dir: /tmp
+ quadlet_options:
+ - "Label=somelabel=labelvalue"
+ - |
+ [Install]
+ WantedBy=default.target
+ register: quadlet_pod
+
+ - name: Check if files exists
+ stat:
+ path: /tmp/podq.pod
+ register: quadlet_file
- - name: Check that slirp4netns is idempotent
+ - name: Check output is correct for Quadlet container in /tmp/podq.pod file
assert:
that:
- - slip4net_pod is not changed
- - slip4net_cont is not changed
-
- - name: Run pod2 with different network slirp4netns
+ - quadlet_file.stat.exists
+
+ - name: Check for the existence of lines in /tmp/podq.pod
+ lineinfile:
+ path: /tmp/podq.pod
+ line: "{{ item }}"
+ state: present
+ check_mode: yes
+ register: line_check
+ loop:
+ - "[Pod]"
+ - "Network=examplenet"
+ - "PodName=podq"
+ - "PublishPort=8000:8001"
+ - "Volume=/tmp:/data"
+ - "Volume=/whocares:/data2:ro"
+ - "PodmanArgs=--add-host host1"
+ - "PodmanArgs=--share net"
+ - "PodmanArgs=--subuidname username1"
+ - "PodmanArgs=--userns auto"
+ - "PodmanArgs=--add-host host1"
+ - "Label=somelabel=labelvalue"
+ - "WantedBy=default.target"
+ loop_control:
+ label: "{{ item }}"
+
+ - name: Fail the task if any line is not present
+ fail:
+ msg: "The following line is not present in /tmp/podq.pod: {{ item.item }}"
+ when: item.changed
+ loop: "{{ line_check.results }}"
+ loop_control:
+ label: "{{ item.item }}"
+
+ - name: Create a Quadlet pod file - same
containers.podman.podman_pod:
executable: "{{ test_executable | default('podman') }}"
- name: pod2
- state: started
- network: slirp4netns:outbound_addr=10.10.10.47
- register: slip4net_pod2
+ name: podq
+ state: quadlet
+ network: examplenet
+ share: net
+ subuidname: username1
+ userns: auto
+ publish: 8000:8001
+ add_host:
+ - host1
+ volume:
+ - /tmp:/data
+ - /whocares:/data2:ro
+ quadlet_dir: /tmp
+ quadlet_options:
+ - "Label=somelabel=labelvalue"
+ - |
+ [Install]
+ WantedBy=default.target
+ register: quad2
+
+ - name: Check if quadlet changed
+ assert:
+ that:
+ - quad2 is not changed
- - name: Run container1 in different pod slirp4netns
- containers.podman.podman_container:
+ - name: Create a Quadlet pod file - different
+ containers.podman.podman_pod:
executable: "{{ test_executable | default('podman') }}"
- name: container1
- image: alpine
- command: top
- pod: pod2
- state: started
- register: slip4net_cont2
-
- - name: Check that slirp4netns is idempotent and changed
+ name: podq
+ state: quadlet
+ network: examplenet
+ share: net
+ subuidname: username1
+ userns: auto
+ publish: 8000:8001
+ add_host:
+ - host1
+ volume:
+ - /tmp:/newdata
+ - /whocares:/data2:ro
+ quadlet_dir: /tmp
+ quadlet_options:
+ - "Label=somelabel=labelvalue"
+ - |
+ [Install]
+ WantedBy=default.target
+ register: quad3
+
+ - name: Print diff
+ debug:
+ var: quad3.diff
+
+ - name: Check if changed and diff
assert:
that:
- - slip4net_pod2 is changed
- - slip4net_cont2 is changed
+ - quad3 is changed
+ - "'newdata' in quad3.diff.after"
always:
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/resource-limit.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/resource-limit.yml
index 94017d9f9..8727d6e50 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/resource-limit.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_pod/tasks/resource-limit.yml
@@ -11,6 +11,7 @@
- name: Create pod for limiting resources
containers.podman.podman_pod:
+ executable: "{{ test_executable | default('podman') }}"
name: limited-pod
state: created
blkio_weight: "{{ limit.blkio_weight }}"
@@ -20,6 +21,7 @@
- name: Get information on pod for limiting resources
containers.podman.podman_pod_info:
+ executable: "{{ test_executable | default('podman') }}"
name: limited-pod
register: pod_info
@@ -34,5 +36,6 @@
always:
- name: Cleanup
containers.podman.podman_pod:
+ executable: "{{ test_executable | default('podman') }}"
name: limited-pod
state: absent
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_prune/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_prune/tasks/main.yml
index 804543fe5..6e1a328af 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_prune/tasks/main.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_prune/tasks/main.yml
@@ -9,6 +9,7 @@
# Create objects to be pruned
- name: Create container
containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ cname }}"
image: quay.io/podman/hello:latest
state: present
@@ -16,12 +17,14 @@
- name: Create network
containers.podman.podman_network:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ nname }}"
state: present
register: network
- name: Create volume
containers.podman.podman_volume:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ vname }}"
state: present
register: volume
@@ -29,12 +32,14 @@
# Prune objects
- name: Prune objects
containers.podman.podman_prune:
+ executable: "{{ test_executable | default('podman') }}"
container: true
network: true
volume: true
- name: Check if container exists
containers.podman.podman_container_info:
+ executable: "{{ test_executable | default('podman') }}"
register: container_exists
- name: Check if podman network exists
@@ -43,6 +48,7 @@
- name: Check if podman volume exists
containers.podman.podman_volume_info:
+ executable: "{{ test_executable | default('podman') }}"
register: volume_exists
- name: Verify assertions for network, container and volume
@@ -58,6 +64,7 @@
# Test with filters
- name: Prune objects with filters
containers.podman.podman_prune:
+ executable: "{{ test_executable | default('podman') }}"
image: true
image_filters:
dangling_only: false
@@ -65,6 +72,7 @@
- name: Check if image exists
containers.podman.podman_image_info:
+ executable: "{{ test_executable | default('podman') }}"
register: image_exists
- name: Verify assertions for image (with filters)
@@ -74,6 +82,7 @@
- name: Create container
containers.podman.podman_container:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ cname }}"
image: quay.io/podman/hello:latest
state: present
@@ -81,36 +90,43 @@
- name: Create network
containers.podman.podman_network:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ nname }}"
state: present
register: network_system
- name: Create volume
containers.podman.podman_volume:
+ executable: "{{ test_executable | default('podman') }}"
name: "{{ vname }}"
state: present
register: volume_system
- name: System prune
containers.podman.podman_prune:
+ executable: "{{ test_executable | default('podman') }}"
system: true
system_all: true
system_volumes: true
- name: Check if container exists
containers.podman.podman_container_info:
+ executable: "{{ test_executable | default('podman') }}"
register: container_system_exists
- name: Check if podman network exists
containers.podman.podman_network_info:
+ executable: "{{ test_executable | default('podman') }}"
register: network_system_exists
- name: Check if podman volume exists
containers.podman.podman_volume_info:
+ executable: "{{ test_executable | default('podman') }}"
register: volume_system_exists
- name: Check if image exists
containers.podman.podman_image_info:
+ executable: "{{ test_executable | default('podman') }}"
register: image_system_exists
- name: Verify assertions for system
diff --git a/ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml b/ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml
index 144a39f63..9d43f3f1c 100644
--- a/ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml
+++ b/ansible_collections/containers/podman/tests/integration/targets/podman_volume/tasks/main.yml
@@ -161,6 +161,134 @@
- info10 is failed
- delete.volume == {}
+ - name: Create a Quadlet for volume with filename
+ containers.podman.podman_volume:
+ executable: "{{ test_executable | default('podman') }}"
+ name: testvol
+ state: quadlet
+ quadlet_dir: /tmp
+ quadlet_filename: customfile
+
+ - name: Check if files exists
+ stat:
+ path: /tmp/customfile.volume
+ register: quadlet_file_custom
+
+ - name: Fail if no file is present
+ assert:
+ that:
+ - quadlet_file_custom.stat.exists
+
+ - name: Create quadlet volume file
+ containers.podman.podman_volume:
+ executable: "{{ test_executable | default('podman') }}"
+ name: testvol
+ state: quadlet
+ driver: local
+ label:
+ namelabel: value
+ foo: bar
+ debug: true
+ options:
+ - "device=/dev/loop1"
+ - "type=ext4"
+ quadlet_dir: /tmp
+ quadlet_options:
+ - "Label=Test=volume"
+ - "Label=test1=value1"
+
+ - name: Check if files exists
+ stat:
+ path: /tmp/testvol.volume
+ register: quadlet_file
+
+ - name: Check output is correct for Quadlet volume in /tmp/testvol.volume file
+ assert:
+ that:
+ - quadlet_file.stat.exists
+
+ - name: Check for the existence of lines in /tmp/testvol.volume
+ lineinfile:
+ path: /tmp/testvol.volume
+ line: "{{ item }}"
+ state: present
+ check_mode: yes
+ register: line_check
+ loop:
+ - "[Volume]"
+ - "VolumeName=testvol"
+ - "Driver=local"
+ - "Label=namelabel=value"
+ - "Label=foo=bar"
+ - "Label=Test=volume"
+ - "Label=test1=value1"
+ - "PodmanArgs=--opt device=/dev/loop1"
+ - "PodmanArgs=--opt type=ext4"
+ - "GlobalArgs=--log-level debug"
+ loop_control:
+ label: "{{ item }}"
+
+ - name: Fail the task if any line is not present
+ fail:
+ msg: "The following line is not present in /tmp/testvol.volume: {{ item.item }}"
+ when: item.changed
+ loop: "{{ line_check.results }}"
+ loop_control:
+ label: "{{ item.item }}"
+
+ - name: Create quadlet volume file - same
+ containers.podman.podman_volume:
+ executable: "{{ test_executable | default('podman') }}"
+ name: testvol
+ state: quadlet
+ driver: local
+ label:
+ namelabel: value
+ foo: bar
+ debug: true
+ options:
+ - "device=/dev/loop1"
+ - "type=ext4"
+ quadlet_dir: /tmp
+ quadlet_options:
+ - "Label=Test=volume"
+ - "Label=test1=value1"
+ register: quad2
+
+ - name: Check if quadlet changed
+ assert:
+ that:
+ - quad2 is not changed
+
+ - name: Create quadlet volume file - different
+ containers.podman.podman_volume:
+ executable: "{{ test_executable | default('podman') }}"
+ name: testvol
+ state: quadlet
+ driver: local
+ label:
+ namelabel: value
+ foo: bar
+ debug: true
+ options:
+ - "device=/dev/loop5"
+ - "type=ext4"
+ quadlet_dir: /tmp
+ quadlet_options:
+ - "Label=Test=volume"
+ - "Label=test1=value1"
+ register: quad3
+
+ - name: Print diff
+ debug:
+ var: quad3.diff
+
+ - name: Check if changed and diff
+ assert:
+ that:
+ - quad3 is changed
+ - "'loop5' in quad3.diff.after"
+
always:
- name: Make sure volume doesn't exist
diff --git a/ansible_collections/containers/podman/tests/sanity/ignore-2.10.txt b/ansible_collections/containers/podman/tests/sanity/ignore-2.10.txt
index f2f4ca9ca..8b2980323 100644
--- a/ansible_collections/containers/podman/tests/sanity/ignore-2.10.txt
+++ b/ansible_collections/containers/podman/tests/sanity/ignore-2.10.txt
@@ -1,2 +1,3 @@
tests/integration/targets/connection_buildah/runme.sh shellcheck:SC2086
tests/integration/targets/connection_podman/runme.sh shellcheck:SC2086
+tests/integration/targets/podman_play/tasks/files/multi-yaml.yml yamllint!skip
diff --git a/ansible_collections/containers/podman/tests/sanity/ignore-2.11.txt b/ansible_collections/containers/podman/tests/sanity/ignore-2.11.txt
index f2f4ca9ca..8b2980323 100644
--- a/ansible_collections/containers/podman/tests/sanity/ignore-2.11.txt
+++ b/ansible_collections/containers/podman/tests/sanity/ignore-2.11.txt
@@ -1,2 +1,3 @@
tests/integration/targets/connection_buildah/runme.sh shellcheck:SC2086
tests/integration/targets/connection_podman/runme.sh shellcheck:SC2086
+tests/integration/targets/podman_play/tasks/files/multi-yaml.yml yamllint!skip
diff --git a/ansible_collections/containers/podman/tests/sanity/ignore-2.12.txt b/ansible_collections/containers/podman/tests/sanity/ignore-2.12.txt
index f2f4ca9ca..8b2980323 100644
--- a/ansible_collections/containers/podman/tests/sanity/ignore-2.12.txt
+++ b/ansible_collections/containers/podman/tests/sanity/ignore-2.12.txt
@@ -1,2 +1,3 @@
tests/integration/targets/connection_buildah/runme.sh shellcheck:SC2086
tests/integration/targets/connection_podman/runme.sh shellcheck:SC2086
+tests/integration/targets/podman_play/tasks/files/multi-yaml.yml yamllint!skip
diff --git a/ansible_collections/containers/podman/tests/sanity/ignore-2.13.txt b/ansible_collections/containers/podman/tests/sanity/ignore-2.13.txt
index f2f4ca9ca..8b2980323 100644
--- a/ansible_collections/containers/podman/tests/sanity/ignore-2.13.txt
+++ b/ansible_collections/containers/podman/tests/sanity/ignore-2.13.txt
@@ -1,2 +1,3 @@
tests/integration/targets/connection_buildah/runme.sh shellcheck:SC2086
tests/integration/targets/connection_podman/runme.sh shellcheck:SC2086
+tests/integration/targets/podman_play/tasks/files/multi-yaml.yml yamllint!skip
diff --git a/ansible_collections/containers/podman/tests/sanity/ignore-2.14.txt b/ansible_collections/containers/podman/tests/sanity/ignore-2.14.txt
index f2f4ca9ca..8b2980323 100644
--- a/ansible_collections/containers/podman/tests/sanity/ignore-2.14.txt
+++ b/ansible_collections/containers/podman/tests/sanity/ignore-2.14.txt
@@ -1,2 +1,3 @@
tests/integration/targets/connection_buildah/runme.sh shellcheck:SC2086
tests/integration/targets/connection_podman/runme.sh shellcheck:SC2086
+tests/integration/targets/podman_play/tasks/files/multi-yaml.yml yamllint!skip
diff --git a/ansible_collections/containers/podman/tests/sanity/ignore-2.15.txt b/ansible_collections/containers/podman/tests/sanity/ignore-2.15.txt
index f2f4ca9ca..8b2980323 100644
--- a/ansible_collections/containers/podman/tests/sanity/ignore-2.15.txt
+++ b/ansible_collections/containers/podman/tests/sanity/ignore-2.15.txt
@@ -1,2 +1,3 @@
tests/integration/targets/connection_buildah/runme.sh shellcheck:SC2086
tests/integration/targets/connection_podman/runme.sh shellcheck:SC2086
+tests/integration/targets/podman_play/tasks/files/multi-yaml.yml yamllint!skip
diff --git a/ansible_collections/containers/podman/tests/sanity/ignore-2.16.txt b/ansible_collections/containers/podman/tests/sanity/ignore-2.16.txt
index f2f4ca9ca..8b2980323 100644
--- a/ansible_collections/containers/podman/tests/sanity/ignore-2.16.txt
+++ b/ansible_collections/containers/podman/tests/sanity/ignore-2.16.txt
@@ -1,2 +1,3 @@
tests/integration/targets/connection_buildah/runme.sh shellcheck:SC2086
tests/integration/targets/connection_podman/runme.sh shellcheck:SC2086
+tests/integration/targets/podman_play/tasks/files/multi-yaml.yml yamllint!skip
diff --git a/ansible_collections/containers/podman/tests/sanity/ignore-2.17.txt b/ansible_collections/containers/podman/tests/sanity/ignore-2.17.txt
index f2f4ca9ca..8b2980323 100644
--- a/ansible_collections/containers/podman/tests/sanity/ignore-2.17.txt
+++ b/ansible_collections/containers/podman/tests/sanity/ignore-2.17.txt
@@ -1,2 +1,3 @@
tests/integration/targets/connection_buildah/runme.sh shellcheck:SC2086
tests/integration/targets/connection_podman/runme.sh shellcheck:SC2086
+tests/integration/targets/podman_play/tasks/files/multi-yaml.yml yamllint!skip
diff --git a/ansible_collections/containers/podman/tests/sanity/ignore-2.18.txt b/ansible_collections/containers/podman/tests/sanity/ignore-2.18.txt
index f2f4ca9ca..8b2980323 100644
--- a/ansible_collections/containers/podman/tests/sanity/ignore-2.18.txt
+++ b/ansible_collections/containers/podman/tests/sanity/ignore-2.18.txt
@@ -1,2 +1,3 @@
tests/integration/targets/connection_buildah/runme.sh shellcheck:SC2086
tests/integration/targets/connection_podman/runme.sh shellcheck:SC2086
+tests/integration/targets/podman_play/tasks/files/multi-yaml.yml yamllint!skip
diff --git a/ansible_collections/containers/podman/tests/sanity/ignore-2.9.txt b/ansible_collections/containers/podman/tests/sanity/ignore-2.9.txt
index f2f4ca9ca..8b2980323 100644
--- a/ansible_collections/containers/podman/tests/sanity/ignore-2.9.txt
+++ b/ansible_collections/containers/podman/tests/sanity/ignore-2.9.txt
@@ -1,2 +1,3 @@
tests/integration/targets/connection_buildah/runme.sh shellcheck:SC2086
tests/integration/targets/connection_podman/runme.sh shellcheck:SC2086
+tests/integration/targets/podman_play/tasks/files/multi-yaml.yml yamllint!skip