diff --git a/changelogs/fragments/2000-fix-vmware-guest-idempotency-with-dvswitch.yml b/changelogs/fragments/2000-fix-vmware-guest-idempotency-with-dvswitch.yml new file mode 100644 index 000000000..72c1a0b21 --- /dev/null +++ b/changelogs/fragments/2000-fix-vmware-guest-idempotency-with-dvswitch.yml @@ -0,0 +1,3 @@ +bugfixes: + - vmware_guest - Fix vmware_guest always reporting change when using dvswitch. + (https://github.com/ansible-collections/community.vmware/pull/2000). diff --git a/plugins/modules/vmware_guest.py b/plugins/modules/vmware_guest.py index eb3923038..63f4367fc 100644 --- a/plugins/modules/vmware_guest.py +++ b/plugins/modules/vmware_guest.py @@ -1936,8 +1936,15 @@ def configure_network(self, vm_obj): nic_change_detected = True if nic.device.deviceInfo.summary != network_name: - nic.device.deviceInfo.summary = network_name - nic_change_detected = True + if 'DVSwitch' not in nic.device.deviceInfo.summary: + nic.device.deviceInfo.summary = network_name + nic_change_detected = True + else: + pg = find_obj(self.content, [vim.DistributedVirtualPortgroup], network_name) + if pg is None or nic.device.backing.port.portgroupKey != pg.key: + nic.device.deviceInfo.summary = network_name + nic_change_detected = True + if 'device_type' in network_devices[key]: device = self.device_helper.nic_device_type.get(network_devices[key]['device_type']) if not isinstance(nic.device, device):