ansible-collections / community.vmware

Ansible Collection for VMware
GNU General Public License v3.0
349 stars 335 forks source link

[community.vmware.vmware_vm_info] does not return tags nor attributes from vCenter 6.7 and 6.0 #1256

Closed s-blottk closed 2 years ago

s-blottk commented 2 years ago
SUMMARY

When running this plugin on vCenter 6.7 or 6.0 no attributes nor tags values are returned, although these are set for the specific VM.

ISSUE TYPE
COMPONENT NAME

community.vmware.vmware_vm_info

ANSIBLE VERSION

ansible 2.9.27 config file = /root/ansible/infrastructure-monitoring-dev-ansible/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible python version = 2.7.5 (default, Nov 16 2020, 22:23:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

COLLECTION VERSION
most recent
CONFIGURATION
ANSIBLE_SSH_ARGS(/root/ansible/infrastructure-monitoring-dev-ansible/ansible.cfg) = -o ForwardAgent=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s -o ProxyCommand="nc -x 10.116.219.201:808
DEFAULT_ASK_PASS(/root/ansible/infrastructure-monitoring-dev-ansible/ansible.cfg) = False
DEFAULT_BECOME(/root/ansible/infrastructure-monitoring-dev-ansible/ansible.cfg) = True
DEFAULT_BECOME_ASK_PASS(/root/ansible/infrastructure-monitoring-dev-ansible/ansible.cfg) = False
DEFAULT_BECOME_METHOD(/root/ansible/infrastructure-monitoring-dev-ansible/ansible.cfg) = sudo
DEFAULT_BECOME_USER(/root/ansible/infrastructure-monitoring-dev-ansible/ansible.cfg) = root
DEFAULT_HOST_LIST(/root/ansible/infrastructure-monitoring-dev-ansible/ansible.cfg) = [u'/root/ansible/infrastructure-monitoring-dev-ansible/inventory/inventory']
DEFAULT_REMOTE_USER(/root/ansible/infrastructure-monitoring-dev-ansible/ansible.cfg) = root
HOST_KEY_CHECKING(/root/ansible/infrastructure-monitoring-dev-ansible/ansible.cfg) = False
OS / ENVIRONMENT

Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-1160.53.1.el7.x86_64 Architecture: x86-64

STEPS TO REPRODUCE

usual execution of the playbook

 - name: Get virtual machine info
  community.vmware.vmware_vm_info:
    hostname: "{{ r_vmware_pull_vm_data_hostname }}"
    username: "{{ r_vmware_pull_vm_data_username }}"
    password: "{{ r_vmware_pull_vm_data_pw }}"
    vm_type: vm
    validate_certs: no
    ## NEEDS TO BE ADAPTED ##
    folder: "{{ folderOfVM }}"
  delegate_to: localhost
  register: vm_info`
EXPECTED RESULTS

Tags should contain keys and values. Attributes are empty in json output as well. I am looking for a key which value I can manipulate on the VMware vSphere UI, that makes the VM unique to me.

ACTUAL RESULTS

JSON output from vCenter 6.7:

 {
   "failed":false,
   "u""virtual_machines":[
      {
         "u""guest_name":"u""otn-ac-bck-cp14",
         "u""datacenter":"u""otn-div-ac",
         "u""guest_fullname":"u""Microsoft Windows Server 2016 or later (64-bit)",
         "u""uuid":"u""420aba05-9f1c-2210-25af-f5f725059530",
         "u""tags":[

         ],
         "u""esxi_hostname":"u""otn-ac-esxi-m01.localdomain",
         "u""cluster":"u""MGMT-Infra",
         "u""moid":"u""vm-144504",
         "u""datastore_url":[
            {
               "u""url":"u""/vmfs/volumes/60f80355-d0b5e5f9-44b1-1402ec8a1328",
               "u""name":"u""otn-ac-esxi-m01-LOCAL-DATA"
            }
         ],
         "u""vm_network":{
            "u""00:50:56:8a:bf:7c":{
               "u""ipv4":[
                  "u""10.116.216.206"
               ],
               "u""ipv6":[
                  "u""fe80::1d8f:2f01:e447:8f09"
               ]
            }
         },
         "u""mac_address":[
            "u""00:50:56:8a:bf:7c"
         ],
         "u""attributes":{

         },
         "u""folder":"u""/otn-div-ac/vm/BackUp",
         "u""power_state":"u""poweredOn",
         "u""ip_address":"u""10.116.216.206"
      }

Vcenter6 7

JSON output from vCenter 6.0:

 {
   "u""guest_name":"u""otn-ac-bck-cp05",
   "u""datacenter":"u""OTN-CLOUD",
   "u""guest_fullname":"u""Microsoft Windows Server 2016 (64-bit)",
   "u""uuid":"u""4221f57f-052b-5b01-b298-7ff6eaf66114",
   "u""tags":[

   ],
   "u""esxi_hostname":"u""otn-cloud-m04.localdomain,
   "u""cluster":"u""OTN-CLOUD-MGMT",
   "u""moid":"u""vm-81023",
   "u""datastore_url":[
      {
         "u""url":"u""/vmfs/volumes/46d62b0b-df770e0c",
         "u""name":"u""DCC2-NFS-MGMTdatastore-DeDup-04"
      }
   ],
   "u""vm_network":{
      "u""00:50:56:a1:5a:4b":{
         "u""ipv4":[
            "u""10.116.216.197"
         ],
         "u""ipv6":[
            "u""fe80::f8bf:438a:19ff:de61"
         ]
      }
   },
   "u""mac_address":[
      "u""00:50:56:a1:5a:4b"
   ],
   "u""attributes":{

   },
   "u""folder":"u""/OTN-CLOUD/vm/Backup_Servers",
   "u""power_state":"u""poweredOn",
   "u""ip_address":"u""10.116.216.197"
}

Vcenter6 0

Akasurde commented 2 years ago

@s-blottk Thanks for reporting this issue. Please use show_tag parameter in vmware_vm_info (which is false by-default) to show tags.