Skip to content

Commit

Permalink
[ignore] set method for file output write in checkmode for aci_rest
Browse files Browse the repository at this point in the history
  • Loading branch information
akinross committed Sep 1, 2023
1 parent edb07d6 commit a786ff6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/module_utils/aci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion plugins/modules/aci_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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":
Expand All @@ -448,6 +449,7 @@ def main():
aci.result["changed"] = True

# Report success

aci.exit_json(**aci.result)


Expand Down

0 comments on commit a786ff6

Please sign in to comment.