From ba113a57410dcc5534d6571f8ff4db9cbd9227bc Mon Sep 17 00:00:00 2001 From: Mario Lenz Date: Mon, 28 Apr 2025 19:42:49 +0200 Subject: [PATCH 1/2] Fix ansible-core 2.19 compatibility --- .../2391-core-2.19.compatibility.yml | 9 +++ plugins/module_utils/vm_device_helper.py | 52 ++++++++-------- plugins/modules/vmware_guest_controller.py | 4 +- plugins/modules/vmware_guest_disk.py | 6 +- .../modules/vmware_target_canonical_info.py | 4 +- .../vmware_cluster_info/tasks/main.yml | 10 ++-- .../vmware_datacenter_info/tasks/main.yml | 8 +-- .../vmware_dvs_portgroup_info/tasks/main.yml | 4 +- .../vmware_host_config_info/tasks/main.yml | 8 +-- .../vmware_host_dns_info/tasks/main.yml | 8 +-- .../vmware_host_scsidisk_info/tasks/main.yml | 8 +-- ...re_object_custom_attributes_info_tests.yml | 60 +++++++++---------- 12 files changed, 95 insertions(+), 86 deletions(-) create mode 100644 changelogs/fragments/2391-core-2.19.compatibility.yml diff --git a/changelogs/fragments/2391-core-2.19.compatibility.yml b/changelogs/fragments/2391-core-2.19.compatibility.yml new file mode 100644 index 0000000000..bf53789c75 --- /dev/null +++ b/changelogs/fragments/2391-core-2.19.compatibility.yml @@ -0,0 +1,9 @@ +bugfixes: + - vm_device_helper - Fix an issue with ansible-core 2.19 + (https://github.com/ansible-collections/community.vmware/pull/2391). + - vmware_guest_controller - Fix an issue with ansible-core 2.19 + (https://github.com/ansible-collections/community.vmware/pull/2391). + - vmware_guest_disk - Fix an issue with ansible-core 2.19 + (https://github.com/ansible-collections/community.vmware/pull/2391). + - vmware_target_canonical_info - Fix an issue with ansible-core 2.19 + (https://github.com/ansible-collections/community.vmware/pull/2391). diff --git a/plugins/module_utils/vm_device_helper.py b/plugins/module_utils/vm_device_helper.py index e75431da56..a7d3c70da2 100644 --- a/plugins/module_utils/vm_device_helper.py +++ b/plugins/module_utils/vm_device_helper.py @@ -430,7 +430,7 @@ def gather_disk_info(self, vm_obj): for controller in vm_obj.config.hardware.device: for name, type in self.disk_ctl_device_type.items(): if isinstance(controller, type): - controller_info[controller_index] = dict( + controller_info[str(controller_index)] = dict( key=controller.key, controller_type=name, bus_number=controller.busNumber, @@ -448,7 +448,7 @@ def gather_disk_info(self, vm_obj): if disk.shares is None: disk.shares = vim.SharesInfo() - disks_info[disk_index] = dict( + disks_info[str(disk_index)] = dict( key=disk.key, label=disk.deviceInfo.label, summary=disk.deviceInfo.summary, @@ -470,48 +470,48 @@ def gather_disk_info(self, vm_obj): capacity_in_bytes=disk.capacityInBytes, ) if isinstance(disk.backing, vim.vm.device.VirtualDisk.FlatVer1BackingInfo): - disks_info[disk_index]['backing_type'] = 'FlatVer1' + disks_info[str(disk_index)]['backing_type'] = 'FlatVer1' elif isinstance(disk.backing, vim.vm.device.VirtualDisk.FlatVer2BackingInfo): - disks_info[disk_index]['backing_type'] = 'FlatVer2' - disks_info[disk_index]['backing_thinprovisioned'] = disk.backing.thinProvisioned - disks_info[disk_index]['backing_eagerlyscrub'] = disk.backing.eagerlyScrub + disks_info[str(disk_index)]['backing_type'] = 'FlatVer2' + disks_info[str(disk_index)]['backing_thinprovisioned'] = disk.backing.thinProvisioned + disks_info[str(disk_index)]['backing_eagerlyscrub'] = disk.backing.eagerlyScrub elif isinstance(disk.backing, vim.vm.device.VirtualDisk.LocalPMemBackingInfo): - disks_info[disk_index]['backing_type'] = 'LocalPMem' - disks_info[disk_index]['backing_volumeuuid'] = disk.backing.volumeUUID + disks_info[str(disk_index)]['backing_type'] = 'LocalPMem' + disks_info[str(disk_index)]['backing_volumeuuid'] = disk.backing.volumeUUID elif isinstance(disk.backing, vim.vm.device.VirtualDisk.PartitionedRawDiskVer2BackingInfo): - disks_info[disk_index]['backing_type'] = 'PartitionedRawDiskVer2' - disks_info[disk_index]['backing_descriptorfilename'] = disk.backing.descriptorFileName + disks_info[str(disk_index)]['backing_type'] = 'PartitionedRawDiskVer2' + disks_info[str(disk_index)]['backing_descriptorfilename'] = disk.backing.descriptorFileName elif isinstance(disk.backing, vim.vm.device.VirtualDisk.RawDiskMappingVer1BackingInfo): - disks_info[disk_index]['backing_type'] = 'RawDiskMappingVer1' - disks_info[disk_index]['backing_devicename'] = disk.backing.deviceName - disks_info[disk_index]['backing_lunuuid'] = disk.backing.lunUuid - disks_info[disk_index]['backing_compatibility_mode'] = disk.backing.compatibilityMode + disks_info[str(disk_index)]['backing_type'] = 'RawDiskMappingVer1' + disks_info[str(disk_index)]['backing_devicename'] = disk.backing.deviceName + disks_info[str(disk_index)]['backing_lunuuid'] = disk.backing.lunUuid + disks_info[str(disk_index)]['backing_compatibility_mode'] = disk.backing.compatibilityMode elif isinstance(disk.backing, vim.vm.device.VirtualDisk.RawDiskVer2BackingInfo): - disks_info[disk_index]['backing_type'] = 'RawDiskVer2' - disks_info[disk_index]['backing_descriptorfilename'] = disk.backing.descriptorFileName + disks_info[str(disk_index)]['backing_type'] = 'RawDiskVer2' + disks_info[str(disk_index)]['backing_descriptorfilename'] = disk.backing.descriptorFileName elif isinstance(disk.backing, vim.vm.device.VirtualDisk.SeSparseBackingInfo): - disks_info[disk_index]['backing_type'] = 'SeSparse' + disks_info[str(disk_index)]['backing_type'] = 'SeSparse' elif isinstance(disk.backing, vim.vm.device.VirtualDisk.SparseVer1BackingInfo): - disks_info[disk_index]['backing_type'] = 'SparseVer1' - disks_info[disk_index]['backing_spaceusedinkb'] = disk.backing.spaceUsedInKB - disks_info[disk_index]['backing_split'] = disk.backing.split + disks_info[str(disk_index)]['backing_type'] = 'SparseVer1' + disks_info[str(disk_index)]['backing_spaceusedinkb'] = disk.backing.spaceUsedInKB + disks_info[str(disk_index)]['backing_split'] = disk.backing.split elif isinstance(disk.backing, vim.vm.device.VirtualDisk.SparseVer2BackingInfo): - disks_info[disk_index]['backing_type'] = 'SparseVer2' - disks_info[disk_index]['backing_spaceusedinkb'] = disk.backing.spaceUsedInKB - disks_info[disk_index]['backing_split'] = disk.backing.split + disks_info[str(disk_index)]['backing_type'] = 'SparseVer2' + disks_info[str(disk_index)]['backing_spaceusedinkb'] = disk.backing.spaceUsedInKB + disks_info[str(disk_index)]['backing_split'] = disk.backing.split for controller_index in range(len(controller_info)): - if controller_info[controller_index]['key'] == disks_info[disk_index]['controller_key']: - disks_info[disk_index]['controller_bus_number'] = controller_info[controller_index]['bus_number'] - disks_info[disk_index]['controller_type'] = controller_info[controller_index]['controller_type'] + if controller_info[str(controller_index)]['key'] == disks_info[str(disk_index)]['controller_key']: + disks_info[str(disk_index)]['controller_bus_number'] = controller_info[str(controller_index)]['bus_number'] + disks_info[str(disk_index)]['controller_type'] = controller_info[str(controller_index)]['controller_type'] disk_index += 1 return disks_info diff --git a/plugins/modules/vmware_guest_controller.py b/plugins/modules/vmware_guest_controller.py index 1857ad51f2..78af19eb3a 100644 --- a/plugins/modules/vmware_guest_controller.py +++ b/plugins/modules/vmware_guest_controller.py @@ -345,7 +345,7 @@ def gather_disk_controller_facts(self): for device in self.current_vm_obj.config.hardware.device: ctl_facts_dict = dict() if isinstance(device, tuple(self.controller_types.values())): - ctl_facts_dict[device.busNumber] = dict( + ctl_facts_dict[str(device.busNumber)] = dict( controller_summary=device.deviceInfo.summary, controller_label=device.deviceInfo.label, controller_busnumber=device.busNumber, @@ -355,7 +355,7 @@ def gather_disk_controller_facts(self): controller_disks_devicekey=device.device, ) if hasattr(device, 'sharedBus'): - ctl_facts_dict[device.busNumber]['controller_bus_sharing'] = device.sharedBus + ctl_facts_dict[str(device.busNumber)]['controller_bus_sharing'] = device.sharedBus if isinstance(device, tuple(self.device_helper.scsi_device_type.values())): disk_ctl_facts['scsi'].update(ctl_facts_dict) if isinstance(device, self.device_helper.nvme_device_type): diff --git a/plugins/modules/vmware_guest_disk.py b/plugins/modules/vmware_guest_disk.py index 047ba8b39f..99d53d3c65 100644 --- a/plugins/modules/vmware_guest_disk.py +++ b/plugins/modules/vmware_guest_disk.py @@ -750,7 +750,7 @@ def ensure_disks(self, vm_obj=None): if disk_change: self.config_spec.deviceChange.append(disk_spec) disk_change_list.append(disk_change) - results['disk_changes'][disk['disk_index']] = "Disk reconfigured." + results['disk_changes'][str(disk['disk_index'])] = "Disk reconfigured." elif disk['state'] == 'absent': # Disk already exists, deleting @@ -762,7 +762,7 @@ def ensure_disks(self, vm_obj=None): self.config_spec.deviceChange.append(disk_spec) disk_change = True disk_change_list.append(disk_change) - results['disk_changes'][disk['disk_index']] = "Disk deleted." + results['disk_changes'][str(disk['disk_index'])] = "Disk deleted." break if disk_found: @@ -804,7 +804,7 @@ def ensure_disks(self, vm_obj=None): self.config_spec.deviceChange.append(disk_spec) disk_change = True disk_change_list.append(disk_change) - results['disk_changes'][disk['disk_index']] = "Disk created." + results['disk_changes'][str(disk['disk_index'])] = "Disk created." break if disk_change: # Adding multiple disks in a single attempt raises weird errors diff --git a/plugins/modules/vmware_target_canonical_info.py b/plugins/modules/vmware_target_canonical_info.py index 1b8b7bbbcf..efdd361896 100644 --- a/plugins/modules/vmware_target_canonical_info.py +++ b/plugins/modules/vmware_target_canonical_info.py @@ -133,7 +133,7 @@ def gather_scsi_device_info(self): # Associate target number with LUN uuid for target in host.config.storageDevice.scsiTopology.adapter[0].target: for lun in target.lun: - target_lun_uuid[target.target] = lun.scsiLun + target_lun_uuid[str(target.target)] = lun.scsiLun scsi_tgt_info[host.name] = dict( scsilun_canonical=scsilun_canonical, @@ -143,7 +143,7 @@ def gather_scsi_device_info(self): canonical = '' temp_lun_data = scsi_tgt_info[self.esxi_hostname]['target_lun_uuid'] if self.esxi_hostname in scsi_tgt_info and \ - target_id in temp_lun_data: + str(target_id) in temp_lun_data: temp_scsi_data = scsi_tgt_info[self.esxi_hostname]['scsilun_canonical'] temp_target = temp_lun_data[target_id] canonical = temp_scsi_data[temp_target] diff --git a/tests/integration/targets/vmware_cluster_info/tasks/main.yml b/tests/integration/targets/vmware_cluster_info/tasks/main.yml index 834785d91b..a34038d6f8 100644 --- a/tests/integration/targets/vmware_cluster_info/tasks/main.yml +++ b/tests/integration/targets/vmware_cluster_info/tasks/main.yml @@ -19,7 +19,7 @@ name: ensure info are gathered for all clusters assert: that: - - all_cluster_result.clusters + - all_cluster_result.clusters | length > 0 - not all_cluster_result.changed - name: ensure info are all defined @@ -72,7 +72,7 @@ name: Ensure info are gathered for the given cluster assert: that: - - cluster_result.clusters + - cluster_result.clusters | length > 0 - not cluster_result.changed - <<: *vc_cluster_data @@ -99,7 +99,7 @@ - name: Ensure info are gathered for all clusters with properteis assert: that: - - all_cluster_result.clusters + - all_cluster_result.clusters | length > 0 - all_cluster_result.clusters[item].name == item - all_cluster_result.clusters[item].configuration.dasConfig.enabled is defined - all_cluster_result.clusters[item].summary.totalCpu is defined @@ -123,7 +123,7 @@ - name: Ensure info are gathered for the given cluster with properties assert: that: - - cluster_result.clusters + - cluster_result.clusters | length > 0 - cluster_result.clusters[item].name == item - cluster_result.clusters[item].configuration.dasConfig.enabled is defined - cluster_result.clusters[item].summary.totalCpu is defined @@ -191,4 +191,4 @@ - name: "Ensure URL-encoded cluster name" assert: that: - - all_cluster_result.clusters['Cluster/\%'] + - all_cluster_result.clusters['Cluster/\%'] is truthy diff --git a/tests/integration/targets/vmware_datacenter_info/tasks/main.yml b/tests/integration/targets/vmware_datacenter_info/tasks/main.yml index a01a598785..b2f5521e32 100644 --- a/tests/integration/targets/vmware_datacenter_info/tasks/main.yml +++ b/tests/integration/targets/vmware_datacenter_info/tasks/main.yml @@ -19,7 +19,7 @@ - name: Ensure datacenter is present assert: that: - - dc_result.datacenter_info + - dc_result.datacenter_info | length > 0 - name: Gather information about all datacenter in check mode vmware_datacenter_info: @@ -36,7 +36,7 @@ - name: Ensure datacenter is present assert: that: - - dc_result.datacenter_info + - dc_result.datacenter_info | length > 0 - name: Gather information about particular datacenter vmware_datacenter_info: @@ -53,7 +53,7 @@ - name: Ensure datacenter is present assert: that: - - dc_result.datacenter_info + - dc_result.datacenter_info | length > 0 - name: Gather information about particular datacenter in check mode vmware_datacenter_info: @@ -71,4 +71,4 @@ - name: Ensure datacenter is present assert: that: - - dc_result.datacenter_info + - dc_result.datacenter_info | length > 0 diff --git a/tests/integration/targets/vmware_dvs_portgroup_info/tasks/main.yml b/tests/integration/targets/vmware_dvs_portgroup_info/tasks/main.yml index 4c8c689c8d..3b7ae0afb0 100644 --- a/tests/integration/targets/vmware_dvs_portgroup_info/tasks/main.yml +++ b/tests/integration/targets/vmware_dvs_portgroup_info/tasks/main.yml @@ -64,7 +64,7 @@ assert: that: - >- - dvs_results.dvs_portgroup_info.{{ dvswitch1 }} + dvs_results.dvs_portgroup_info['{{ dvswitch1 }}'] | map(attribute='portgroup_name') | select('==', 'dvportgroup\/%') | list @@ -107,4 +107,4 @@ - assert: that: - "dvs_results_0002['dvs_portgroup_info']['DVS0'] is defined" - - dvs_results_0002['dvs_portgroup_info']['DVS0'][0].key + - dvs_results_0002['dvs_portgroup_info']['DVS0'][0].key is truthy diff --git a/tests/integration/targets/vmware_host_config_info/tasks/main.yml b/tests/integration/targets/vmware_host_config_info/tasks/main.yml index 895dec158f..f00e2c579b 100644 --- a/tests/integration/targets/vmware_host_config_info/tasks/main.yml +++ b/tests/integration/targets/vmware_host_config_info/tasks/main.yml @@ -21,7 +21,7 @@ - name: ensure info are gathered for all hosts assert: that: - - all_hosts_result.hosts_info + - all_hosts_result.hosts_info is truthy - name: gather info about all hosts in given cluster in check mode vmware_host_config_info: @@ -36,7 +36,7 @@ - name: ensure info are gathered for all hosts assert: that: - - all_hosts_result_check_mode.hosts_info + - all_hosts_result_check_mode.hosts_info is truthy - name: gather info about a given host in check mode vmware_host_config_info: @@ -50,7 +50,7 @@ - name: ensure info are gathered for all hosts assert: that: - - single_hosts_result_check_mode.hosts_info + - single_hosts_result_check_mode.hosts_info is truthy - name: gather info about a given host vmware_host_config_info: @@ -63,4 +63,4 @@ - name: ensure info are gathered for all hosts assert: that: - - single_hosts_result.hosts_info + - single_hosts_result.hosts_info is truthy diff --git a/tests/integration/targets/vmware_host_dns_info/tasks/main.yml b/tests/integration/targets/vmware_host_dns_info/tasks/main.yml index 0452c7dc47..fa07a70534 100644 --- a/tests/integration/targets/vmware_host_dns_info/tasks/main.yml +++ b/tests/integration/targets/vmware_host_dns_info/tasks/main.yml @@ -19,7 +19,7 @@ - name: ensure DNS info are gathered for all hosts in given cluster assert: that: - - all_hosts_dns_result.hosts_dns_info + - all_hosts_dns_result.hosts_dns_info is truthy - not all_hosts_dns_result.changed - name: gather DNS info about host system @@ -34,7 +34,7 @@ - name: ensure DNS info are gathered about host system assert: that: - - all_hosts_dns_result.hosts_dns_info + - all_hosts_dns_result.hosts_dns_info is truthy - not all_hosts_dns_result.changed - name: gather DNS info about all hosts in given cluster in check mode @@ -50,7 +50,7 @@ - name: ensure DNS info are gathered for all hosts in given cluster assert: that: - - all_hosts_dns_result_check_mode.hosts_dns_info + - all_hosts_dns_result_check_mode.hosts_dns_info is truthy - not all_hosts_dns_result_check_mode.changed - name: gather DNS info about host system in check mode @@ -66,5 +66,5 @@ - name: ensure DNS info are gathered about host system assert: that: - - all_hosts_dns_result_check_mode.hosts_dns_info + - all_hosts_dns_result_check_mode.hosts_dns_info is truthy - not all_hosts_dns_result_check_mode.changed diff --git a/tests/integration/targets/vmware_host_scsidisk_info/tasks/main.yml b/tests/integration/targets/vmware_host_scsidisk_info/tasks/main.yml index fc0e930fa6..aa8615a6d0 100644 --- a/tests/integration/targets/vmware_host_scsidisk_info/tasks/main.yml +++ b/tests/integration/targets/vmware_host_scsidisk_info/tasks/main.yml @@ -20,7 +20,7 @@ - name: Ensure SCSI disks info are gathered for all hosts in given cluster assert: that: - - all_hosts_disk_result.hosts_scsidisk_info + - all_hosts_disk_result.hosts_scsidisk_info is truthy - not all_hosts_disk_result.changed - name: Gather SCSI disks info about host system @@ -35,7 +35,7 @@ - name: Ensure SCSI disks info are gathered about host system assert: that: - - all_hosts_disk_result.hosts_scsidisk_info + - all_hosts_disk_result.hosts_scsidisk_info is truthy - not all_hosts_disk_result.changed - name: Gather SCSI disks info about all hosts in given cluster in check mode @@ -51,7 +51,7 @@ - name: Ensure SCSI disks info are gathered for all hosts in given cluster assert: that: - - all_hosts_disk_result_check_mode.hosts_scsidisk_info + - all_hosts_disk_result_check_mode.hosts_scsidisk_info is truthy - not all_hosts_disk_result_check_mode.changed - name: Ensure SCSI disks info about host system in check mode @@ -67,5 +67,5 @@ - name: Ensure SCSI disks info are gathered about host system assert: that: - - all_hosts_disk_result_check_mode.hosts_scsidisk_info + - all_hosts_disk_result_check_mode.hosts_scsidisk_info is truthy - not all_hosts_disk_result_check_mode.changed diff --git a/tests/integration/targets/vmware_object_custom_attributes_info/tasks/vmware_object_custom_attributes_info_tests.yml b/tests/integration/targets/vmware_object_custom_attributes_info/tasks/vmware_object_custom_attributes_info_tests.yml index 04f0ff556a..ae4273d8a5 100644 --- a/tests/integration/targets/vmware_object_custom_attributes_info/tasks/vmware_object_custom_attributes_info_tests.yml +++ b/tests/integration/targets/vmware_object_custom_attributes_info/tasks/vmware_object_custom_attributes_info_tests.yml @@ -15,20 +15,20 @@ - name: Make sure if custom attributes exist assert: that: + - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example01') is truthy - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example01') - - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example01') - | selectattr('type', 'equalto', 'VirtualMachine') - - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1') + | selectattr('type', 'equalto', 'VirtualMachine') is truthy + - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1') is truthy + - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example02') is truthy - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example02') - - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example02') - | selectattr('type', 'equalto', 'VirtualMachine') - - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2') + | selectattr('type', 'equalto', 'VirtualMachine') is truthy + - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2') is truthy + - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example03_global') is truthy - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example03_global') - - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example03_global') - | selectattr('type', 'equalto', 'Global') - - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test3') + | selectattr('type', 'equalto', 'Global') is truthy + - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test3') is truthy - name: Gather custom attributes of an ESXi community.vmware.vmware_object_custom_attributes_info: @@ -43,15 +43,15 @@ - name: Make sure if custom attributes exist assert: that: - - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01') - - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01') + - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01') is truthy + - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01') is truthy | selectattr('type', 'equalto', 'HostSystem') - - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1') + - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1') is truthy - - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02') - - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02') + - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02') is truthy + - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02') is truthy | selectattr('type', 'equalto', 'HostSystem') - - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2') + - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2') is truthy - name: Gather custom attributes of a virtual machine with moid community.vmware.vmware_object_custom_attributes_info: @@ -66,20 +66,20 @@ - name: Make sure if custom attributes exist assert: that: + - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example01') is truthy - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example01') - - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example01') - | selectattr('type', 'equalto', 'VirtualMachine') - - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1') + | selectattr('type', 'equalto', 'VirtualMachine') is truthy + - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1') is truthy + - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example02') is truthy - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example02') - - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example02') - | selectattr('type', 'equalto', 'VirtualMachine') - - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2') + | selectattr('type', 'equalto', 'VirtualMachine') is truthy + - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2') is truthy + - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example03_global') is truthy - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example03_global') - - vm_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'vm_example03_global') - | selectattr('type', 'equalto', 'Global') - - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test3') + | selectattr('type', 'equalto', 'Global') is truthy + - vm_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test3') is truthy - name: Gather custom attributes of an ESXi with moid community.vmware.vmware_object_custom_attributes_info: @@ -94,12 +94,12 @@ - name: Make sure if custom attributes exist assert: that: + - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01') is truthy - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01') - - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01') - | selectattr('type', 'equalto', 'HostSystem') - - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1') + | selectattr('type', 'equalto', 'HostSystem') is truthy + - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1') is truthy + - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02') is truthy - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02') - - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02') - | selectattr('type', 'equalto', 'HostSystem') - - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2') + | selectattr('type', 'equalto', 'HostSystem') is truthy + - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2') is truthy From e153f034a4a54daa04a8d9d1634fec0676052379 Mon Sep 17 00:00:00 2001 From: Mario Lenz Date: Fri, 9 May 2025 05:45:05 +0200 Subject: [PATCH 2/2] foo --- .../tasks/vmware_object_custom_attributes_info_tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/targets/vmware_object_custom_attributes_info/tasks/vmware_object_custom_attributes_info_tests.yml b/tests/integration/targets/vmware_object_custom_attributes_info/tasks/vmware_object_custom_attributes_info_tests.yml index ae4273d8a5..73758966f4 100644 --- a/tests/integration/targets/vmware_object_custom_attributes_info/tasks/vmware_object_custom_attributes_info_tests.yml +++ b/tests/integration/targets/vmware_object_custom_attributes_info/tasks/vmware_object_custom_attributes_info_tests.yml @@ -44,13 +44,13 @@ assert: that: - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01') is truthy - - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01') is truthy - | selectattr('type', 'equalto', 'HostSystem') + - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example01') + | selectattr('type', 'equalto', 'HostSystem') is truthy - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test1') is truthy - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02') is truthy - - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02') is truthy - | selectattr('type', 'equalto', 'HostSystem') + - esxi_custom_attributes_result.custom_attributes | selectattr('attribute', 'equalto', 'esxi_example02') + | selectattr('type', 'equalto', 'HostSystem') is truthy - esxi_custom_attributes_result.custom_attributes | selectattr('value', 'equalto', 'test2') is truthy - name: Gather custom attributes of a virtual machine with moid