diff --git a/changelogs/fragments/403_fix_vmware_guest_info.yml b/changelogs/fragments/403_fix_vmware_guest_info.yml new file mode 100644 index 0000000000..1392d62c4c --- /dev/null +++ b/changelogs/fragments/403_fix_vmware_guest_info.yml @@ -0,0 +1,2 @@ +minor_changes: +- vmware_guest_info - Fix get tags API call (https://github.com/ansible-collections/community.vmware/issues/403). diff --git a/plugins/modules/vmware_guest_info.py b/plugins/modules/vmware_guest_info.py index f2bde6482f..e9426a0b30 100644 --- a/plugins/modules/vmware_guest_info.py +++ b/plugins/modules/vmware_guest_info.py @@ -294,9 +294,7 @@ def main(): vm_rest_client = VmwareTag(module) instance.update( - tags=vm_rest_client.get_vm_tags(vm_rest_client.tag_service, - vm_rest_client.tag_association_svc, - vm_mid=vm._moId) + tags=vm_rest_client.get_tags_for_vm(vm_mid=vm._moId) ) module.exit_json(instance=instance) except Exception as exc: diff --git a/tests/integration/targets/vmware_tag/tasks/tag_manager_ops.yml b/tests/integration/targets/vmware_tag/tasks/tag_manager_ops.yml index 14158cfca0..64be9eaa0e 100644 --- a/tests/integration/targets/vmware_tag/tasks/tag_manager_ops.yml +++ b/tests/integration/targets/vmware_tag/tasks/tag_manager_ops.yml @@ -53,6 +53,22 @@ that: - tag_manager_ops.changed + - name: Get tags from a virtual machine + vmware_guest_info: + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + validate_certs: no + name: "{{ vm_name }}" + register: r + + - name: Check if tag information is available + assert: + that: + - not r.changed + - r['instance']['tags'] is defined + - "{{ r['instance']['tags'][0]['name'] == Tag_Name[0] }}" + - <<: *tag_assign name: Add tags to a virtual machine again