From 785ba6286706469a3a848500b9f1ca134729e798 Mon Sep 17 00:00:00 2001 From: Nik Reiman Date: Mon, 7 Oct 2019 18:11:50 +0200 Subject: [PATCH] vmware: Only add configured network interfaces to facts (#28552) This change effectively filters out any network interfaces which were not explicitly configured for the guest. This fixes some unexpected behaviour where a machine with multiple IP addresses (for example, when Docker is installed, an internal IPv4 interface is added to communicate with the container) would show one of the internal addresses in the 'ipv4' field, but then no other information about the corresponding hardware interface. --- changelogs/fragments/vmware-only-add-configured-interfaces.yml | 2 ++ lib/ansible/module_utils/vmware.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/vmware-only-add-configured-interfaces.yml diff --git a/changelogs/fragments/vmware-only-add-configured-interfaces.yml b/changelogs/fragments/vmware-only-add-configured-interfaces.yml new file mode 100644 index 00000000000..903d7578495 --- /dev/null +++ b/changelogs/fragments/vmware-only-add-configured-interfaces.yml @@ -0,0 +1,2 @@ +minor_changes: + - vmware.py - Only add configured network interfaces to facts. diff --git a/lib/ansible/module_utils/vmware.py b/lib/ansible/module_utils/vmware.py index 5b88cab32e3..f6c1d1b7020 100644 --- a/lib/ansible/module_utils/vmware.py +++ b/lib/ansible/module_utils/vmware.py @@ -365,7 +365,8 @@ def gather_vm_facts(content, vm): vmnet = _get_vm_prop(vm, ('guest', 'net')) if vmnet: for device in vmnet: - net_dict[device.macAddress] = list(device.ipAddress) + if device.deviceConfigId > 0: + net_dict[device.macAddress] = list(device.ipAddress) if vm.guest.ipAddress: if ':' in vm.guest.ipAddress: