summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNik Reiman <nik.reiman@ableton.com>2019-10-07 18:11:50 +0200
committerAbhijeet Kasurde <akasurde@redhat.com>2019-10-07 21:41:50 +0530
commit785ba6286706469a3a848500b9f1ca134729e798 (patch)
treed4f7cd64700f38556986f6f361addc1cfa52922a
parente48202838cfa7eeddb15590cce9f4b7fbaf182c4 (diff)
downloadansible-785ba6286706469a3a848500b9f1ca134729e798.tar.gz
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.
-rw-r--r--changelogs/fragments/vmware-only-add-configured-interfaces.yml2
-rw-r--r--lib/ansible/module_utils/vmware.py3
2 files changed, 4 insertions, 1 deletions
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 0000000000..903d757849
--- /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 5b88cab32e..f6c1d1b702 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: