Update for a podman_container from collection
And removing docker.io from podman container tests. Change-Id: I29f94783637264b6938c1f03925ed700bd8acafc
This commit is contained in:
parent
82659a89a7
commit
b6ca89d194
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# Copyright (c) 2020 Red Hat
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
|
def run_podman_command(module, executable='podman', args=None, expected_rc=0, ignore_errors=False):
|
||||||
|
if not isinstance(executable, list):
|
||||||
|
command = [executable]
|
||||||
|
if args is not None:
|
||||||
|
command.extend(args)
|
||||||
|
rc, out, err = module.run_command(command)
|
||||||
|
if not ignore_errors and rc != expected_rc:
|
||||||
|
module.fail_json(
|
||||||
|
msg='Failed to run {command} {args}: {err}'.format(
|
||||||
|
command=command, args=args, err=err))
|
||||||
|
return rc, out, err
|
||||||
|
|
||||||
|
|
||||||
|
def lower_keys(x):
|
||||||
|
if isinstance(x, list):
|
||||||
|
return [lower_keys(v) for v in x]
|
||||||
|
elif isinstance(x, dict):
|
||||||
|
return dict((k.lower(), lower_keys(v)) for k, v in x.items())
|
||||||
|
else:
|
||||||
|
return x
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -10,7 +10,7 @@
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: absent
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- "alpine:3.7"
|
- "ubi-minimal"
|
||||||
- "container"
|
- "container"
|
||||||
- "container2"
|
- "container2"
|
||||||
|
|
||||||
|
@ -48,13 +48,13 @@
|
||||||
|
|
||||||
- name: Ensure image doesn't exist
|
- name: Ensure image doesn't exist
|
||||||
podman_image:
|
podman_image:
|
||||||
name: alpine:3.7
|
name: registry.access.redhat.com/ubi8/ubi-minimal
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Check pulling image
|
- name: Check pulling image
|
||||||
podman_container:
|
podman_container:
|
||||||
name: container
|
name: container
|
||||||
image: alpine:3.7
|
image: registry.access.redhat.com/ubi8/ubi-minimal
|
||||||
state: present
|
state: present
|
||||||
command: sleep 1d
|
command: sleep 1d
|
||||||
register: image
|
register: image
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
- name: Check using already pulled image
|
- name: Check using already pulled image
|
||||||
podman_container:
|
podman_container:
|
||||||
name: container2
|
name: container2
|
||||||
image: alpine:3.7
|
image: registry.access.redhat.com/ubi8/ubi-minimal
|
||||||
state: present
|
state: present
|
||||||
command: sleep 1d
|
command: sleep 1d
|
||||||
register: image2
|
register: image2
|
||||||
|
@ -73,12 +73,12 @@
|
||||||
- image is changed
|
- image is changed
|
||||||
- image.container is defined
|
- image.container is defined
|
||||||
- image.container['State']['Running']
|
- image.container['State']['Running']
|
||||||
- "'pulled image alpine:3.7' in image.actions"
|
- "'pulled image registry.access.redhat.com/ubi8/ubi-minimal' in image.actions"
|
||||||
- "'started container' in image.actions"
|
- "'started container' in image.actions"
|
||||||
- image2 is changed
|
- image2 is changed
|
||||||
- image2.container is defined
|
- image2.container is defined
|
||||||
- image2.container['State']['Running']
|
- image2.container['State']['Running']
|
||||||
- "'pulled image alpine:3.7' not in image2.actions"
|
- "'pulled image registry.access.redhat.com/ubi8/ubi-minimal' not in image2.actions"
|
||||||
- "'started container2' in image2.actions"
|
- "'started container2' in image2.actions"
|
||||||
fail_msg: Pulling image test failed!
|
fail_msg: Pulling image test failed!
|
||||||
success_msg: Pulling image test passed!
|
success_msg: Pulling image test passed!
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
- name: Force container recreate
|
- name: Force container recreate
|
||||||
podman_container:
|
podman_container:
|
||||||
name: container
|
name: container
|
||||||
image: alpine
|
image: registry.access.redhat.com/ubi8/ubi-minimal
|
||||||
state: present
|
state: present
|
||||||
command: sleep 1d
|
command: sleep 1d
|
||||||
recreate: true
|
recreate: true
|
||||||
|
@ -173,7 +173,7 @@
|
||||||
- name: Create container, but don't run
|
- name: Create container, but don't run
|
||||||
podman_container:
|
podman_container:
|
||||||
name: container
|
name: container
|
||||||
image: alpine:3.7
|
image: registry.access.redhat.com/ubi8/ubi-minimal
|
||||||
state: stopped
|
state: stopped
|
||||||
command: sleep 1d
|
command: sleep 1d
|
||||||
register: created
|
register: created
|
||||||
|
@ -197,7 +197,7 @@
|
||||||
- name: Start container that was deleted
|
- name: Start container that was deleted
|
||||||
podman_container:
|
podman_container:
|
||||||
name: container
|
name: container
|
||||||
image: alpine:3.7
|
image: registry.access.redhat.com/ubi8/ubi-minimal
|
||||||
state: started
|
state: started
|
||||||
command: sleep 1d
|
command: sleep 1d
|
||||||
register: started
|
register: started
|
||||||
|
@ -208,7 +208,7 @@
|
||||||
- started is changed
|
- started is changed
|
||||||
- started.container is defined
|
- started.container is defined
|
||||||
- started.container['State']['Running']
|
- started.container['State']['Running']
|
||||||
- "'pulled image alpine:3.7' not in started.actions"
|
- "'pulled image registry.access.redhat.com/ubi8/ubi-minimal' not in started.actions"
|
||||||
|
|
||||||
- name: Delete started container
|
- name: Delete started container
|
||||||
podman_container:
|
podman_container:
|
||||||
|
@ -239,7 +239,7 @@
|
||||||
- name: Recreate container with parameters
|
- name: Recreate container with parameters
|
||||||
podman_container:
|
podman_container:
|
||||||
name: container
|
name: container
|
||||||
image: docker.io/alpine:3.7
|
image: registry.access.redhat.com/ubi8/ubi-minimal
|
||||||
state: started
|
state: started
|
||||||
command: sleep 1d
|
command: sleep 1d
|
||||||
recreate: true
|
recreate: true
|
||||||
|
@ -306,7 +306,7 @@
|
||||||
- "'TEST=1' in test.container['Config']['Env']"
|
- "'TEST=1' in test.container['Config']['Env']"
|
||||||
- "'BOOL=False' in test.container['Config']['Env']"
|
- "'BOOL=False' in test.container['Config']['Env']"
|
||||||
# test labels
|
# test labels
|
||||||
- test.container['Config']['Labels'] | length == 2
|
- test.container['Config']['Labels'] | length >= 2
|
||||||
- test.container['Config']['Labels']['somelabel'] == "labelvalue"
|
- test.container['Config']['Labels']['somelabel'] == "labelvalue"
|
||||||
- test.container['Config']['Labels']['otheralbe'] == "othervalue"
|
- test.container['Config']['Labels']['otheralbe'] == "othervalue"
|
||||||
# test mounts
|
# test mounts
|
||||||
|
@ -326,14 +326,14 @@
|
||||||
- name: Check basic idempotency of running container
|
- name: Check basic idempotency of running container
|
||||||
podman_container:
|
podman_container:
|
||||||
name: testidem
|
name: testidem
|
||||||
image: docker.io/alpine
|
image: registry.access.redhat.com/ubi8/ubi-minimal
|
||||||
state: present
|
state: present
|
||||||
command: sleep 20m
|
command: sleep 20m
|
||||||
|
|
||||||
- name: Check basic idempotency of running container - run it again
|
- name: Check basic idempotency of running container - run it again
|
||||||
podman_container:
|
podman_container:
|
||||||
name: testidem
|
name: testidem
|
||||||
image: alpine:latest
|
image: ubi-minimal:latest
|
||||||
state: present
|
state: present
|
||||||
command: sleep 20m
|
command: sleep 20m
|
||||||
register: idem
|
register: idem
|
||||||
|
@ -346,7 +346,7 @@
|
||||||
- name: Run changed container (with tty enabled)
|
- name: Run changed container (with tty enabled)
|
||||||
podman_container:
|
podman_container:
|
||||||
name: testidem
|
name: testidem
|
||||||
image: alpine
|
image: ubi-minimal
|
||||||
state: present
|
state: present
|
||||||
command: sleep 20m
|
command: sleep 20m
|
||||||
tty: true
|
tty: true
|
||||||
|
@ -360,7 +360,7 @@
|
||||||
- name: Run changed container without specifying an option, use defaults
|
- name: Run changed container without specifying an option, use defaults
|
||||||
podman_container:
|
podman_container:
|
||||||
name: testidem
|
name: testidem
|
||||||
image: alpine
|
image: ubi-minimal
|
||||||
state: present
|
state: present
|
||||||
command: sleep 20m
|
command: sleep 20m
|
||||||
register: idem2
|
register: idem2
|
||||||
|
@ -384,7 +384,7 @@
|
||||||
- name: Check basic idempotency of pod container
|
- name: Check basic idempotency of pod container
|
||||||
podman_container:
|
podman_container:
|
||||||
name: testidem-pod
|
name: testidem-pod
|
||||||
image: docker.io/alpine
|
image: registry.access.redhat.com/ubi8/ubi-minimal
|
||||||
state: present
|
state: present
|
||||||
command: sleep 20m
|
command: sleep 20m
|
||||||
pod: "new:testidempod"
|
pod: "new:testidempod"
|
||||||
|
@ -392,7 +392,7 @@
|
||||||
- name: Check basic idempotency of pod container - run it again
|
- name: Check basic idempotency of pod container - run it again
|
||||||
podman_container:
|
podman_container:
|
||||||
name: testidem-pod
|
name: testidem-pod
|
||||||
image: alpine:latest
|
image: ubi-minimal:latest
|
||||||
state: present
|
state: present
|
||||||
command: sleep 20m
|
command: sleep 20m
|
||||||
pod: testidempod
|
pod: testidempod
|
||||||
|
@ -406,7 +406,7 @@
|
||||||
- name: Run changed pod container (with tty enabled)
|
- name: Run changed pod container (with tty enabled)
|
||||||
podman_container:
|
podman_container:
|
||||||
name: testidem-pod
|
name: testidem-pod
|
||||||
image: alpine
|
image: ubi-minimal
|
||||||
state: present
|
state: present
|
||||||
command: sleep 20m
|
command: sleep 20m
|
||||||
tty: true
|
tty: true
|
||||||
|
@ -423,30 +423,18 @@
|
||||||
name: testidem-pod
|
name: testidem-pod
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Run three containers at once
|
|
||||||
podman_containers:
|
|
||||||
containers:
|
|
||||||
- name: alpine
|
|
||||||
image: alpine
|
|
||||||
command: sleep 1d
|
|
||||||
- name: web
|
|
||||||
image: nginx
|
|
||||||
- name: test
|
|
||||||
image: python:3-alpine
|
|
||||||
command: python -V
|
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Delete all container leftovers from tests
|
- name: Delete all container leftovers from tests
|
||||||
podman_container:
|
podman_container:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: absent
|
state: absent
|
||||||
loop:
|
loop:
|
||||||
- "alpine:3.7"
|
|
||||||
- "container"
|
- "container"
|
||||||
- "container2"
|
- "container2"
|
||||||
- "alpine"
|
- "ubi-minimal"
|
||||||
- "web"
|
- "web"
|
||||||
- "test"
|
- "test"
|
||||||
|
- "testidem"
|
||||||
|
|
||||||
- name: Remove pod
|
- name: Remove pod
|
||||||
shell: podman pod rm -f testidempod
|
shell: podman pod rm -f testidempod
|
||||||
|
|
Loading…
Reference in New Issue