From ffc1208283efa84e5b039bf382abace1ec34e963 Mon Sep 17 00:00:00 2001 From: duanetoler <133727241+duanetoler@users.noreply.github.com> Date: Sun, 15 Sep 2024 03:35:47 -0400 Subject: [PATCH] Fix api_command() failure handling: for other-than-200 http code, if command is 'show-..', then return Ansible module.fail_json instead of discard_and_fail. All others still discard_and_fail. (#148) --- plugins/module_utils/checkpoint.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/module_utils/checkpoint.py b/plugins/module_utils/checkpoint.py index 34bbd8c..666f10d 100644 --- a/plugins/module_utils/checkpoint.py +++ b/plugins/module_utils/checkpoint.py @@ -564,7 +564,10 @@ def api_command(module, command): handle_publish(module, connection, version) else: - discard_and_fail(module, code, response, connection, version) + if command.startswith("show"): + module.fail_json(msg=parse_fail_message(code, response)) + else: + discard_and_fail(module, code, response, connection, version) return result