diff --git a/plugins/module_utils/mso.py b/plugins/module_utils/mso.py index 091561af..9f05e6ec 100644 --- a/plugins/module_utils/mso.py +++ b/plugins/module_utils/mso.py @@ -1491,7 +1491,7 @@ def input_validation(self, attr_name, attr_value, required_attributes, target_ob elif empty_attributes: self.module.fail_json(msg="When the '{0}' is '{1}', the {2} attributes must be set".format(attr_name, attr_value, empty_attributes)) - # Temporary introduced method to handle nd specific query without introducing a dependency on the nd collection in code + # Temporarily introduced method to handle nd specific query without introducing a dependency on the nd collection in code # Copied method from the nd collection: https://github.com/CiscoDevNet/ansible-nd/blob/master/plugins/module_utils/nd.py#L221 # TODO: Refactor the code for bundled nd collection def nd_request(self, path, method=None, data=None, file=None, qs=None, prefix="", file_key="file", output_format="json", ignore_not_found_error=False): diff --git a/plugins/modules/mso_tenant.py b/plugins/modules/mso_tenant.py index 89d1e15c..e39a2bbc 100644 --- a/plugins/modules/mso_tenant.py +++ b/plugins/modules/mso_tenant.py @@ -179,12 +179,11 @@ def main(): else: mso.existing = mso.query_objs(path) - mso.previous = mso.existing - if state == "query": pass elif state == "absent": + mso.previous = mso.existing if mso.existing: if module.check_mode: mso.existing = {} @@ -193,6 +192,8 @@ def main(): mso.existing = mso.request(path, method="DELETE") elif state == "present": + mso.previous = mso.existing + # Convert sites and users sites = mso.lookup_sites(module.params.get("sites")) users = mso.lookup_users(module.params.get("users"))