From 21d4e239b4df328a66cdfc8944de5b81e1b13f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A9ri=20Le=20Bouder?= Date: Mon, 13 May 2019 14:16:10 -0400 Subject: [PATCH] vmware_vm_facts: fix the test with vcsim The VM is call `ha-host_VM0`, not `DC0_H0_VM0`. This commit adjusts the test to make it more resilient if the VM name is different. --- .../targets/vmware_vm_facts/tasks/main.yml | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/test/integration/targets/vmware_vm_facts/tasks/main.yml b/test/integration/targets/vmware_vm_facts/tasks/main.yml index 74430a421ce..06caaf31a05 100644 --- a/test/integration/targets/vmware_vm_facts/tasks/main.yml +++ b/test/integration/targets/vmware_vm_facts/tasks/main.yml @@ -20,22 +20,20 @@ register: vm_facts_0001 - debug: var=vm_facts_0001 +- set_fact: + first_vm: "{{ vm_facts_0001['virtual_machines'][0] }}" - &vm_fact_check name: Verify if VM facts exist assert: that: - - "item.esxi_hostname is defined" - - "item.guest_fullname is defined" - - "item.ip_address is defined" - - "item.mac_address is defined" - - "item.power_state is defined" - - "item.uuid is defined" - - "item.vm_network is defined" - with_items: - - "{{ vm_facts_0001.virtual_machines | json_query(query) }}" - vars: - query: "[?guest_name=='DC0_H0_VM0']" + - first_vm.esxi_hostname is defined + - first_vm.guest_fullname is defined + - first_vm.ip_address is defined + - first_vm.mac_address is defined + - first_vm.power_state is defined + - first_vm.uuid is defined + - first_vm.vm_network is defined - <<: *vm_data name: Get facts about available vms in check mode @@ -50,7 +48,7 @@ hostname: "{{ vcenter_hostname }}" username: "{{ vcenter_username }}" password: "{{ vcenter_password }}" - name: "DC0_H0_VM0" + name: "{{ first_vm.guest_name }}" register: folder_path_info - set_fact: