From a786ff638f0cc1bb3a0f01be4337c4aacf57924d Mon Sep 17 00:00:00 2001 From: akinross Date: Fri, 1 Sep 2023 12:00:10 +0200 Subject: [PATCH] [ignore] set method for file output write in checkmode for aci_rest --- plugins/module_utils/aci.py | 2 +- plugins/modules/aci_rest.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/aci.py b/plugins/module_utils/aci.py index 205552fb2..45f8bfca6 100644 --- a/plugins/module_utils/aci.py +++ b/plugins/module_utils/aci.py @@ -1446,7 +1446,7 @@ def exit_json(self, filter_existing=None, **kwargs): self.result["sent"] = self.config self.result["proposed"] = self.proposed - elif self.__class__.__name__ == "ACIRESTModule" and self.method in ["POST", "DELETE"]: + elif self.__class__.__name__ == "ACIRESTModule" and self.method != "GET": self.result["proposed"] = self.proposed self.dump_json() diff --git a/plugins/modules/aci_rest.py b/plugins/modules/aci_rest.py index ef01ded64..aba2a8875 100644 --- a/plugins/modules/aci_rest.py +++ b/plugins/modules/aci_rest.py @@ -374,6 +374,7 @@ def main(): module.fail_json(msg="Failed to find REST API payload type (neither .xml nor .json).") aci = ACIRESTModule(module) + aci.stdout = aci.params.get("method").upper() aci.result["status"] = -1 # Ensure we always return a status # We include the payload as it may be templated @@ -411,7 +412,6 @@ def main(): aci.url = update_qsl(aci.url, {"rsp-subtree": "modified"}) method = aci.params.get("method").upper() - # Perform request if not aci.module.check_mode: resp, info = aci.api_call(method, aci.url, data=payload, return_response=True) @@ -440,6 +440,7 @@ def main(): with open(output_path, "a") as output_file: output_file.write(str(payload)) else: + aci.method = method if rest_type == "json": aci.proposed = json.loads(payload) elif rest_type == "xml": @@ -448,6 +449,7 @@ def main(): aci.result["changed"] = True # Report success + aci.exit_json(**aci.result)