From fb27f88d1c27bdf9037540f6c0bcc8f40a959b13 Mon Sep 17 00:00:00 2001 From: Sagi Shnaidman Date: Thu, 30 Nov 2023 15:48:46 +0200 Subject: [PATCH] Fail if systemd generation failed and it's explicitly set Fix #675 If we explicitly set to generate systemd with parameters, fail the module if the generation failed. Signed-off-by: Sagi Shnaidman --- plugins/module_utils/podman/common.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/module_utils/podman/common.py b/plugins/module_utils/podman/common.py index 23f9e6f9..ea5b4502 100644 --- a/plugins/module_utils/podman/common.py +++ b/plugins/module_utils/podman/common.py @@ -142,6 +142,8 @@ def generate_systemd(module, module_params, name, version): if rc != 0: module.log( "PODMAN-CONTAINER-DEBUG: Error generating systemd: %s" % err) + if sysconf: + module.fail_json(msg="Error generating systemd: %s" % err) return result else: try: @@ -194,6 +196,8 @@ def generate_systemd(module, module_params, name, version): except Exception as e: module.log( "PODMAN-CONTAINER-DEBUG: Error writing systemd: %s" % e) + if sysconf: + module.fail_json(msg="Error writing systemd: %s" % e) return result