From 223321e7e23b910a3950ba6a9204c01e4894d047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A9ri=20Le=20Bouder?= Date: Thu, 4 Apr 2019 13:14:58 -0400 Subject: [PATCH] vmware_datastore_facts: empty list if none found When `vmware_datastore_facts` does not fine any datastore, it raises an error. This is not consistent with the other _facts modules. It should just return an empty list instead. --- changelogs/fragments/vmware_datastore_facts.yaml | 2 ++ .../modules/cloud/vmware/vmware_datastore_facts.py | 10 +--------- 2 files changed, 3 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/vmware_datastore_facts.yaml diff --git a/changelogs/fragments/vmware_datastore_facts.yaml b/changelogs/fragments/vmware_datastore_facts.yaml new file mode 100644 index 00000000000..66e6896d70e --- /dev/null +++ b/changelogs/fragments/vmware_datastore_facts.yaml @@ -0,0 +1,2 @@ +minor_changes: + - vmware_datastore_facts - When no datastore was found, returns an empty list. diff --git a/lib/ansible/modules/cloud/vmware/vmware_datastore_facts.py b/lib/ansible/modules/cloud/vmware/vmware_datastore_facts.py index 041b0882942..816adffbb85 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_datastore_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_datastore_facts.py @@ -277,15 +277,7 @@ def main(): result['datastores'] = datastores - # found a datastore - if datastores: - module.exit_json(**result) - else: - msg = "Unable to gather datastore facts" - if module.params['name']: - msg += " for %(name)s" % module.params - msg += " in datacenter %(datacenter)s" % module.params - module.fail_json(msg=msg) + module.exit_json(**result) if __name__ == '__main__':