ansible-collections / community.vmware

Ansible Collection for VMware
GNU General Public License v3.0
348 stars 338 forks source link

portgroup is empty if vmk is placed on a dv-portgroup #413

Open Christian-Kolrep opened 4 years ago

Christian-Kolrep commented 4 years ago

Hi,

I just want to delete all vmkernel port on a vmhost except for vmk0 because its the one for management.

This is what the taks looks like, and it works for one specific vmkernel port.

- name: delete vmk
    vmware_vmkernel:
        hostname: '{{ vcenter_server }}'
        username: '{{ vcenter_user }}'
        password: '{{ vcenter_pass }}'
        esxi_hostname: '{{ inventory_hostname }}'
        dvswitch: "my_dvswitch"
        portgroup_name: "my_dvportgroup"
        device: "vmk1"
        state: absent
        validate_certs: false
    delegate_to: localhost

since you have to specify the portgroup_name and dvswitch i tried to get the needed informations with this task.

- name: Gather VMKernel info about ESXi Host
      vmware_vmkernel_info:
        hostname: '{{ vcenter_server }}'
        username: '{{ vcenter_user }}'
        password: '{{ vcenter_pass }}'
        esxi_hostname: '{{ inventory_hostname }}'
        validate_certs: false
      delegate_to: localhost
      register: host_vmks

But as you can see the portgroup field is empty (if it is a distributed virtual portgroup).

ok: [Myhost] => {
    "msg": {
        "changed": false,
        "failed": false,
        "host_vmk_info": {
            "Myhost": [
                {
                    "device": "vmk0",
                    "dhcp": false,
                    "enable_ft": false,
                    "enable_management": true,
                    "enable_vmotion": false,
                    "enable_vsan": false,
                    "ipv4_address": "172.25.17.88",
                    "ipv4_subnet_mask": "255.255.252.0",
                    "key": "key-vim.host.VirtualNic-vmk0",
                    "mac": "00:50:56:67:40:fd",
                    "mtu": 1500,
                    "portgroup": "Verwaltung",
                    "stack": "defaultTcpipStack"
                },
                {
                    "device": "vmk2",
                    "dhcp": false,
                    "enable_ft": false,
                    "enable_management": false,
                    "enable_vmotion": true,
                    "enable_vsan": false,
                    "ipv4_address": "172.31.19.72",
                    "ipv4_subnet_mask": "255.255.252.0",
                    "key": "key-vim.host.VirtualNic-vmk2",
                    "mac": "00:50:56:63:8f:ea",
                    "mtu": 1500,
                    "portgroup": "",
                    "stack": "defaultTcpipStack"
                },
                {
                    "device": "vmk1",
                    "dhcp": false,
                    "enable_ft": false,
                    "enable_management": false,
                    "enable_vmotion": true,
                    "enable_vsan": false,
                    "ipv4_address": "172.31.19.71",
                    "ipv4_subnet_mask": "255.255.252.0",
                    "key": "key-vim.host.VirtualNic-vmk1",
                    "mac": "00:50:56:6a:c8:07",
                    "mtu": 1500,
                    "portgroup": "",
                    "stack": "defaultTcpipStack"
                },
                {
                    "device": "vmk3",
                    "dhcp": false,
                    "enable_ft": false,
                    "enable_management": false,
                    "enable_vmotion": false,
                    "enable_vsan": false,
                    "ipv4_address": "172.31.7.1",
                    "ipv4_subnet_mask": "255.255.254.0",
                    "key": "key-vim.host.VirtualNic-vmk3",
                    "mac": "00:50:56:6a:d2:00",
                    "mtu": 1500,
                    "portgroup": "",
                    "stack": "defaultTcpipStack"
                }
            ]
        }
    }
}

Any ideas how to fix the problem? I just want to delete the vmkernel ports. :disappointed:

ansibullbot commented 3 years ago

Files identified in the description: None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 3 years ago

@Christian-Kolrep: Greetings! Thanks for taking the time to open this issue. In order for the community to handle your issue effectively, we need a bit more information.

Here are the items we could not find in your description:

Please set the description of this issue with this template: https://raw.githubusercontent.com/ansible/ansible/devel/.github/ISSUE_TEMPLATE/bug_report.md

click here for bot help

Akasurde commented 3 years ago

!component =plugins/modules/vmware_vmkernel.py

ansibullbot commented 3 years ago

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 3 years ago

cc @Tomorrow9 @goneri @lparkes @pgbidkar @warthog9 click here for bot help