community.vmware
community.vmware copied to clipboard
DVportgroup name not retrieved
SUMMARY
DVportgroup name not retrieved when using module vmware_host_facts or vmware_vmkernel_info It could be the case with other modules as well
ISSUE TYPE
- Bug Report
COMPONENT NAME
vmware_host_facts vmware_vmkernel_info
ANSIBLE VERSION
ansible 2.10.8
COLLECTION VERSION
community.vmware 1.11.0
Also tested with
community.vmware 1.9.0
CONFIGURATION
DEFAULT_ASK_PASS(/home/nilesh/ansible-collection/ansible.cfg) = False
DEFAULT_HOST_LIST(/home/nilesh/ansible-collection/ansible.cfg) = ['/home/nilesh/ansible-collection/inventory/inventory']
DEFAULT_REMOTE_USER(/home/nilesh/ansible-collection/ansible.cfg) = root
OS / ENVIRONMENT
Ubuntu 20.04.2 LTS RHEL 8.4
STEPS TO REPRODUCE
Define the variables and use example playbook defined on Ansible documentation.
---
- hosts: localhost
connection: local
gather_facts: true
vars:
vcenter_hostname: 'vc.abc.local'
vcenter_username: '[email protected]'
vcenter_password: 'password'
esxi_hostname: 'esxi03.abc.local'
datacenter_name: 'DC'
tasks:
- name: Gather VMKernel info about ESXi Host
community.vmware.vmware_vmkernel_info:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
esxi_hostname: '{{ esxi_hostname }}'
validate_certs: no
delegate_to: localhost
register: host_vmks
- debug:
msg: '{{host_vmks}}'
- name: Gather some info from a host using the vSphere API output schema
community.vmware.vmware_host_facts:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: "{{ esxi_hostname }}"
validate_certs: no
schema: vsphere
properties:
register: host_facts
- debug:
msg: '{{host_facts}}'
EXPECTED RESULTS
Portgroup name of VSS gets listed but not of DVport group. VMK1 is on DVportgroup. VMkernel facts ouput. { "device": "vmk0", "dhcp": false, "enable_ft": false, "enable_management": true, "enable_vmotion": false, "enable_vsan": false, "ipv4_address": "192.168.9.11", "ipv4_subnet_mask": "255.255.255.0", "key": "key-vim.host.VirtualNic-vmk0", "mac": "00:50:56:9d:69:ba", "mtu": 1500, "portgroup": "Management Network", "stack": "defaultTcpipStack" }, { "device": "vmk1", "dhcp": false, "enable_ft": false, "enable_management": false, "enable_vmotion": true, "enable_vsan": false, "ipv4_address": "192.168.9.12", "ipv4_subnet_mask": "255.255.255.0", "key": "key-vim.host.VirtualNic-vmk1", "mac": "00:50:56:6f:5a:23", "mtu": 1500, "portgroup": "vMotion Network", "stack": "defaultTcpipStack" } ]
host_facts output
{ "_vimtype": "vim.host.VirtualNic", "device": "vmk1", "key": "vSphereBackupNFC.key-vim.host.VirtualNic-vmk1", "port": null, "portgroup": "vMotion Network", "spec": { "_vimtype": "vim.host.VirtualNic.Specification", "distributedVirtualPort": { "_vimtype": "vim.dvs.PortConnection", "connectionCookie": 1824643360, "portKey": "6", "portgroupKey": "dvportgroup-12003", "switchUuid": "50 1d b6 70 a7 ab 70 f7-a6 ae 48 59 a2 57 75 e7" },
ACTUAL RESULTS
VMkernel facts ouput. { "device": "vmk0", "dhcp": false, "enable_ft": false, "enable_management": true, "enable_vmotion": false, "enable_vsan": false, "ipv4_address": "192.168.9.11", "ipv4_subnet_mask": "255.255.255.0", "key": "key-vim.host.VirtualNic-vmk0", "mac": "00:50:56:9d:69:ba", "mtu": 1500, "portgroup": "Management Network", "stack": "defaultTcpipStack" }, { "device": "vmk1", "dhcp": false, "enable_ft": false, "enable_management": false, "enable_vmotion": true, "enable_vsan": false, "ipv4_address": "192.168.9.12", "ipv4_subnet_mask": "255.255.255.0", "key": "key-vim.host.VirtualNic-vmk1", "mac": "00:50:56:6f:5a:23", "mtu": 1500, "portgroup": "", "stack": "defaultTcpipStack" } ]
host_facts output
{ "_vimtype": "vim.host.VirtualNic", "device": "vmk1", "key": "vSphereBackupNFC.key-vim.host.VirtualNic-vmk1", "port": null, "portgroup": "", "spec": { "_vimtype": "vim.host.VirtualNic.Specification", "distributedVirtualPort": { "_vimtype": "vim.dvs.PortConnection", "connectionCookie": 1824643360, "portKey": "6", "portgroupKey": "dvportgroup-12003", "switchUuid": "50 1d b6 70 a7 ab 70 f7-a6 ae 48 59 a2 57 75 e7" },
I have the same issue.
I noticed in vCenter 7 MOB that the property portgroup is empty and this is the property that is read by the module.
https://github.com/ansible-collections/community.vmware/blob/3e1a0dbf36cc2472f7c390a6a702ac6fbaf9d5fb/plugins/modules/vmware_vmkernel_info.py#L162
I think the portgroup name has to be looked up via the vnic.spec.distributedVirtualPort.portgroupKey and vnic.spec.distributedVirtualPort.switchUuid.
So the fix will be a little more complex.
I also ran into this same problem today. It would be useful to see the port group for VMKernel ports connected to a DVS.
$ ansible --version
ansible 2.9.27
config file = /home/user/.ansible.cfg
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Mar 25 2022, 11:15:52) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]
$ grep version ~/.ansible/collections/ansible_collections/community/vmware/MANIFEST.json
"version": "2.2.0",