diff --git a/lib/ansible/modules/cloud/vmware/vmware_guest_facts.py b/lib/ansible/modules/cloud/vmware/vmware_guest_facts.py index d067e95d7a..3a04c33b8b 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_guest_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_guest_facts.py @@ -173,7 +173,6 @@ def main(): folder=dict(required=False, type='str', default='/vm'), datacenter=dict(required=True, type='str'), ), - required_together=[('name', 'folder')], required_one_of=[['name', 'uuid']], ) diff --git a/test/integration/targets/vmware_guest_facts/tasks/main.yml b/test/integration/targets/vmware_guest_facts/tasks/main.yml index b79f9e5b0a..22196a7a90 100644 --- a/test/integration/targets/vmware_guest_facts/tasks/main.yml +++ b/test/integration/targets/vmware_guest_facts/tasks/main.yml @@ -80,3 +80,26 @@ that: - "guest_facts_0001['instance']['hw_name'] == vm1 | basename" - "guest_facts_0001['instance']['hw_product_uuid'] is defined" + +- set_fact: vm1_uuid="{{ guest_facts_0001['instance']['hw_product_uuid'] }}" + +- debug: var=vm1_uuid + +# Testcase 0002: Get details about virtual machines using UUID +- name: get list of facts about virtual machines using UUID + vmware_guest_facts: + validate_certs: False + hostname: "{{ vcsim }}" + username: "{{ vcsim_instance['json']['username'] }}" + password: "{{ vcsim_instance['json']['password'] }}" + datacenter: "{{ dc1 | basename }}" + uuid: "{{ vm1_uuid }}" + register: guest_facts_0002 + +- debug: msg="{{ guest_facts_0002 }}" + +- assert: + that: + - "guest_facts_0002['instance']['hw_name'] == vm1 | basename" + - "guest_facts_0002['instance']['hw_product_uuid'] is defined" + - "guest_facts_0002['instance']['hw_product_uuid'] == vm1_uuid"