From 14dc45d7cd20c9bc77817284d8f0c7720a92e5de Mon Sep 17 00:00:00 2001 From: Sagi Shnaidman Date: Wed, 6 May 2020 20:24:53 +0300 Subject: [PATCH] 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. Partial-Bug: #1876893 Change-Id: Ic9f063eac866b25f980f20f86502653289321592 --- .../tasks/tripleo_podman_container_rm.yml | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tripleo_ansible/roles/tripleo_container_rm/tasks/tripleo_podman_container_rm.yml b/tripleo_ansible/roles/tripleo_container_rm/tasks/tripleo_podman_container_rm.yml index d619d082c..953fb3f3e 100644 --- a/tripleo_ansible/roles/tripleo_container_rm/tasks/tripleo_podman_container_rm.yml +++ b/tripleo_ansible/roles/tripleo_container_rm/tasks/tripleo_podman_container_rm.yml @@ -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