diff --git a/plugins/modules/aci_config_snapshot.py b/plugins/modules/aci_config_snapshot.py index 63fffabe9..8bb13307f 100644 --- a/plugins/modules/aci_config_snapshot.py +++ b/plugins/modules/aci_config_snapshot.py @@ -272,7 +272,8 @@ def main(): target_filter={"name": export_policy}, ), ) - + # Variable set for reuse of correct url in get_existing() triggered from exit_json() after query request + reset_url = aci.url aci.get_existing() aci.payload( @@ -293,6 +294,15 @@ def main(): # Create a new Snapshot aci.post_config() + # Query for job information and add to results + # Change state to query else aci.request() will not execute a GET request but POST + aci.params["state"] = "query" + aci.request(path="/api/node/mo/uni/backupst/jobs-[uni/fabric/configexp-{0}].json".format(export_policy)) + aci.result["job_details"] = aci.imdata[0].get("configJobCont", {}) + # Reset state and url to display correct in output and trigger get_existing() function with correct url + aci.url = reset_url + aci.params["state"] = "present" + else: # Prefix the proper url to export_policy if export_policy is not None: diff --git a/tests/integration/targets/aci_config_snapshot/tasks/main.yml b/tests/integration/targets/aci_config_snapshot/tasks/main.yml index 1015b7d67..c4ff71c90 100644 --- a/tests/integration/targets/aci_config_snapshot/tasks/main.yml +++ b/tests/integration/targets/aci_config_snapshot/tasks/main.yml @@ -18,7 +18,6 @@ use_proxy: '{{ aci_use_proxy | default(true) }}' output_level: debug export_policy: anstest - max_count: 10 include_secure: no format: json description: ansible test @@ -27,6 +26,7 @@ - name: update snapshot to include secure and use xml - update works cisco.aci.aci_config_snapshot: <<: *create_snapshot + max_count: 10 include_secure: yes format: xml register: create_update @@ -61,6 +61,9 @@ - invalid_max_count.msg == "Parameter 'max_count' must be a number between 1 and 10" - missing_param is failed - 'missing_param.msg == "state is present but all of the following are missing: export_policy"' + - create.job_details.attributes.dn == "uni/backupst/jobs-[uni/fabric/configexp-anstest]" + - create.job_details.attributes.name == "anstest" + - "'lastJobName' in create.job_details.attributes" - name: query with export_policy cisco.aci.aci_config_snapshot: &query_snapshot