From 4da30fd3fdacb36722b369e921cf42f48da77092 Mon Sep 17 00:00:00 2001 From: Elias Norrby Date: Wed, 24 Feb 2021 12:19:37 +0100 Subject: [PATCH] Attempt graceful stop when recreating container (#203) References: containers/ansible-podman-collections#202 Co-authored-by: Sergey --- plugins/module_utils/podman/podman_container_lib.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/module_utils/podman/podman_container_lib.py b/plugins/module_utils/podman/podman_container_lib.py index b778236..e76f4a1 100644 --- a/plugins/module_utils/podman/podman_container_lib.py +++ b/plugins/module_utils/podman/podman_container_lib.py @@ -1389,11 +1389,15 @@ class PodmanContainer: def recreate(self): """Recreate the container.""" + if self.running: + self.stop() self.delete() self.create() def recreate_run(self): """Recreate and run the container.""" + if self.running: + self.stop() self.delete() self.run()