Stop and remove container with module
For stopping and removing podman container use podman_container
modules which is idempotent. Retry it a few times if it doesn't
pass first time.
For --systemd flag should be defined true or false: "--systemd true"
By default it's true, so can be removed.
Partial-Bug: #1876893
(cherry picked from commit 14dc45d7cd
)
Change-Id: Ic9f063eac866b25f980f20f86502653289321592
This commit is contained in:
parent
7c0f6b1f52
commit
f9ae624da1
|
@ -37,6 +37,7 @@ provisioner:
|
|||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
ANSIBLE_ROLES_PATH: "${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles"
|
||||
ANSIBLE_LIBRARY: "${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}"
|
||||
|
||||
scenario:
|
||||
name: default
|
||||
|
|
|
@ -37,6 +37,7 @@ provisioner:
|
|||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
ANSIBLE_ROLES_PATH: "${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles"
|
||||
ANSIBLE_LIBRARY: "${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}"
|
||||
|
||||
scenario:
|
||||
name: docker
|
||||
|
|
|
@ -32,6 +32,8 @@ provisioner:
|
|||
log: true
|
||||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
ANSIBLE_ROLES_PATH: "${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles"
|
||||
ANSIBLE_LIBRARY: "${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}"
|
||||
|
||||
scenario:
|
||||
test_sequence:
|
||||
|
|
|
@ -32,6 +32,8 @@ provisioner:
|
|||
log: true
|
||||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
ANSIBLE_ROLES_PATH: "${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles"
|
||||
ANSIBLE_LIBRARY: "${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}"
|
||||
|
||||
scenario:
|
||||
test_sequence:
|
||||
|
|
|
@ -32,6 +32,8 @@ provisioner:
|
|||
log: true
|
||||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
ANSIBLE_ROLES_PATH: "${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles"
|
||||
ANSIBLE_LIBRARY: "${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}"
|
||||
|
||||
scenario:
|
||||
test_sequence:
|
||||
|
|
|
@ -78,15 +78,11 @@
|
|||
systemd:
|
||||
daemon_reload: true
|
||||
|
||||
- name: "stat {{ container }} container"
|
||||
command: "podman container exists {{ container }}"
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
register: stat_container
|
||||
|
||||
- name: Stop and remove container
|
||||
command: "podman container rm --force {{ container }}"
|
||||
changed_when: true
|
||||
when:
|
||||
- stat_container.rc is defined
|
||||
- stat_container.rc == 0
|
||||
- name: Stop and remove container if exists
|
||||
podman_container:
|
||||
name: "{{ container }}"
|
||||
state: absent
|
||||
register: result
|
||||
until: result is success
|
||||
retries: 5
|
||||
delay: 10
|
||||
|
|
|
@ -32,10 +32,10 @@
|
|||
state: latest
|
||||
|
||||
- name: Pull container image
|
||||
command: "podman pull centos:8"
|
||||
command: "podman pull fedora"
|
||||
|
||||
- name: Create test containers
|
||||
command: "podman run -itd --systemd --name {{ item }} fedora bash"
|
||||
command: "podman run -itd --name {{ item }} fedora bash"
|
||||
with_items:
|
||||
- podman-container1
|
||||
- podman-container2
|
||||
|
|
Loading…
Reference in New Issue