1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-03-22 02:29:08 +00:00
ansible-podman-collections/tests/integration/targets/podman_container_info/tasks/main.yml
Sergey f1a9456147
Fix conditions in CI jobs (#928)
Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
2025-04-28 00:14:28 +03:00

101 lines
3.4 KiB
YAML

- 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
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: "{{ container_name }}"
state: absent
- name: Get missing container info
containers.podman.podman_container_info:
executable: "{{ test_executable | default('podman') }}"
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:
executable: "{{ test_executable | default('podman') }}"
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:
executable: "{{ test_executable | default('podman') }}"
name: "{{ container_name }}"
register: existing_container
- name: Get mixed existing and non-existing container info
containers.podman.podman_container_info:
executable: "{{ test_executable | default('podman') }}"
name:
- "{{ container_name }}"
- whatever
register: mixed_existing_container
- name: Get all containers info
containers.podman.podman_container_info:
executable: "{{ test_executable | default('podman') }}"
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
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: "{{ container_name }}"
state: absent
- name: Make checks
# https://github.com/containers/podman/issues/9490
assert:
that:
- "'containers' in existing_container"
- existing_container.containers | length > 0
# - "existing_container.containers == podman_inspect_result"
# - all_containers.containers == existing_container.containers
- "'containers' in mixed_existing_container"
- mixed_existing_container.containers | length > 0
# - existing_container.containers == mixed_existing_container.containers
always:
- name: Cleanup
containers.podman.podman_container:
executable: "{{ test_executable | default('podman') }}"
name: "{{ container_name }}"
state: absent