From 055ee048ce987bac7d803cc0110b6fee839ff92c Mon Sep 17 00:00:00 2001 From: Philip Bove Date: Fri, 26 Oct 2018 13:41:58 -0400 Subject: [PATCH] VMware: Fixed vmware fact gathering when no physical interfaces have IP Addresses (#42600) * Changed vmware_guest_facts to accuretly reflect ip as displayed in vcenter * fixed ipv6 check --- lib/ansible/module_utils/vmware.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index 1970b94431..5177f97257 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -352,13 +352,11 @@ def gather_vm_facts(content, vm): for device in vmnet: net_dict[device.macAddress] = list(device.ipAddress) - for dummy, v in iteritems(net_dict): - for ipaddress in v: - if ipaddress: - if '::' in ipaddress: - facts['ipv6'] = ipaddress - else: - facts['ipv4'] = ipaddress + if vm.guest.ipAddress: + if ':' in vm.guest.ipAddress: + facts['ipv6'] = vm.guest.ipAddress + else: + facts['ipv4'] = vm.guest.ipAddress ethernet_idx = 0 for entry in vm.config.hardware.device: