From 7de8ae7e1667852b8b555d856a53990bcc8eceda Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Fri, 27 Nov 2020 09:55:21 +0000 Subject: [PATCH] Prevent creation failure if containers already exists (#23) Fixes: #22 --- lib/molecule_podman/playbooks/create.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/molecule_podman/playbooks/create.yml b/lib/molecule_podman/playbooks/create.yml index 219a757..8d5d914 100644 --- a/lib/molecule_podman/playbooks/create.yml +++ b/lib/molecule_podman/playbooks/create.yml @@ -75,6 +75,12 @@ with_items: "{{ molecule_yml.platforms }}" when: item.override_command | default(true) + # https://github.com/ansible-community/molecule-podman/issues/22 + - name: Remove possible pre-existing containers + shell: > + podman container exists {{ item.name }} && podman rm {{ item.name }} -f || true + with_items: "{{ molecule_yml.platforms }}" + - name: Create molecule instance(s) command: > podman run