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 0000000000..302d9c99be --- /dev/null +++ b/changelogs/fragments/2000-fix-vmware-guest-idempotency-with-dvswitch.yml @@ -0,0 +1,3 @@ +minor_changes: + - 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 1f5a0a818b..a36836da44 100644 --- a/plugins/modules/vmware_guest.py +++ b/plugins/modules/vmware_guest.py @@ -1951,8 +1951,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 not None and 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):