community.vmware.vmware_vmkernel (4.2.0) — module

Manages a VMware VMkernel Adapter of an ESXi host.

Authors: Joseph Callen (@jcpowermac), Russell Teague (@mtnbikenc), Abhijeet Kasurde (@Akasurde), Christian Kotte (@ckotte), Nina Loser (@Nina2244)

Install collection

Install with ansible-galaxy collection install community.vmware:==4.2.0


Add to requirements.yml

  collections:
    - name: community.vmware
      version: 4.2.0

Description

This module can be used to manage the VMKernel adapters / VMKernel network interfaces of an ESXi host.

The module assumes that the host is already configured with the Port Group in case of a vSphere Standard Switch (vSS).

The module assumes that the host is already configured with the Distributed Port Group in case of a vSphere Distributed Switch (vDS).

The module automatically migrates the VMKernel adapter from vSS to vDS or vice versa if present.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
-  name: Add Management vmkernel port using static network type
   community.vmware.vmware_vmkernel:
      hostname: '{{ esxi_hostname }}'
      username: '{{ esxi_username }}'
      password: '{{ esxi_password }}'
      esxi_hostname: '{{ esxi_hostname }}'
      vswitch_name: vSwitch0
      portgroup_name: PG_0001
      network:
        type: 'static'
        ip_address: 192.168.127.10
        subnet_mask: 255.255.255.0
      state: present
      enable_mgmt: true
   delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
-  name: Add Management vmkernel port using DHCP network type
   community.vmware.vmware_vmkernel:
      hostname: '{{ esxi_hostname }}'
      username: '{{ esxi_username }}'
      password: '{{ esxi_password }}'
      esxi_hostname: '{{ esxi_hostname }}'
      vswitch_name: vSwitch0
      portgroup_name: PG_0002
      state: present
      network:
        type: 'dhcp'
      enable_mgmt: true
   delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
-  name: Change IP allocation from static to dhcp
   community.vmware.vmware_vmkernel:
      hostname: '{{ esxi_hostname }}'
      username: '{{ esxi_username }}'
      password: '{{ esxi_password }}'
      esxi_hostname: '{{ esxi_hostname }}'
      vswitch_name: vSwitch0
      portgroup_name: PG_0002
      state: present
      device: vmk1
      network:
        type: 'dhcp'
      enable_mgmt: true
   delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
-  name: Delete VMkernel port
   community.vmware.vmware_vmkernel:
      hostname: '{{ esxi_hostname }}'
      username: '{{ esxi_username }}'
      password: '{{ esxi_password }}'
      esxi_hostname: '{{ esxi_hostname }}'
      vswitch_name: vSwitch0
      portgroup_name: PG_0002
      state: absent
   delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
-  name: Add Management vmkernel port to Distributed Switch
   community.vmware.vmware_vmkernel:
      hostname: '{{ vcenter_hostname }}'
      username: '{{ vcenter_username }}'
      password: '{{ vcenter_password }}'
      esxi_hostname: '{{ esxi_hostname }}'
      dvswitch_name: dvSwitch1
      portgroup_name: dvPG_0001
      network:
        type: 'static'
        ip_address: 192.168.127.10
        subnet_mask: 255.255.255.0
      state: present
      enable_mgmt: true
   delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
-  name: Add vMotion vmkernel port with vMotion TCP/IP stack
   community.vmware.vmware_vmkernel:
      hostname: '{{ vcenter_hostname }}'
      username: '{{ vcenter_username }}'
      password: '{{ vcenter_password }}'
      esxi_hostname: '{{ esxi_hostname }}'
      dvswitch_name: dvSwitch1
      portgroup_name: dvPG_0001
      network:
        type: 'static'
        ip_address: 192.168.127.10
        subnet_mask: 255.255.255.0
        tcpip_stack: vmotion
      state: present
   delegate_to: localhost

Inputs

    
mtu:
    default: 1500
    description:
    - The MTU for the VMKernel interface.
    - The default value of 1500 is valid from version 2.5 and onwards.
    type: int

port:
    default: 443
    description:
    - The port number of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PORT)
      will be used instead.
    type: int

state:
    choices:
    - present
    - absent
    default: present
    description:
    - If set to V(present), the VMKernel adapter will be created with the given specifications.
    - If set to V(absent), the VMKernel adapter will be removed.
    - If set to V(present) and VMKernel adapter exists, the configurations will be updated.
    type: str

device:
    description:
    - Search VMkernel adapter by device name.
    - The parameter is required only in case of O(network.type=dhcp).
    type: str

network:
    default:
      tcpip_stack: default
      type: static
    description:
    - A dictionary of network details.
    suboptions:
      default_gateway:
        description: Default gateway (Override default gateway for this adapter).
        type: str
      ip_address:
        description:
        - Static IP address.
        - Required if O(network.type=static).
        type: str
      subnet_mask:
        description:
        - Static netmask required.
        - Required if O(network.type=static).
        type: str
      tcpip_stack:
        choices:
        - default
        - provisioning
        - vmotion
        - vxlan
        default: default
        description:
        - The TCP/IP stack for the VMKernel interface.
        type: str
      type:
        choices:
        - static
        - dhcp
        default: static
        description:
        - Type of IP assignment.
        type: str
    type: dict

hostname:
    description:
    - The hostname or IP address of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_HOST)
      will be used instead.
    type: str

password:
    aliases:
    - pass
    - pwd
    description:
    - The password of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PASSWORD)
      will be used instead.
    type: str

username:
    aliases:
    - admin
    - user
    description:
    - The username of the vSphere vCenter or ESXi server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_USER)
      will be used instead.
    type: str

enable_ft:
    default: false
    description:
    - Enable Fault Tolerance traffic on the VMKernel adapter.
    - This option is only allowed if the default TCP/IP stack is used.
    type: bool

proxy_host:
    description:
    - Address of a proxy that will receive all HTTPS requests and relay them.
    - The format is a hostname or a IP.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PROXY_HOST)
      will be used instead.
    required: false
    type: str

proxy_port:
    description:
    - Port of the HTTP proxy that will receive all HTTPS requests and relay them.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PROXY_PORT)
      will be used instead.
    required: false
    type: int

enable_mgmt:
    default: false
    description:
    - Enable Management traffic on the VMKernel adapter.
    - This option is only allowed if the default TCP/IP stack is used.
    type: bool

enable_vsan:
    default: false
    description:
    - Enable VSAN traffic on the VMKernel adapter.
    - This option is only allowed if the default TCP/IP stack is used.
    type: bool

vswitch_name:
    aliases:
    - vswitch
    description:
    - The name of the vSwitch where to add the VMKernel interface.
    - Required parameter only if O(state=present).
    - Optional parameter from version 2.5 and onwards.
    type: str

dvswitch_name:
    aliases:
    - dvswitch
    description:
    - The name of the vSphere Distributed Switch (vDS) where to add the VMKernel interface.
    - Required parameter only if O(state=present).
    - Optional parameter from version 2.8 and onwards.
    type: str

esxi_hostname:
    description:
    - Name of ESXi host to which VMKernel is to be managed.
    required: true
    type: str

enable_vmotion:
    default: false
    description:
    - Enable vMotion traffic on the VMKernel adapter.
    - This option is only allowed if the default TCP/IP stack is used.
    - You cannot enable vMotion on an additional adapter if you already have an adapter
      with the vMotion TCP/IP stack configured.
    type: bool

portgroup_name:
    aliases:
    - portgroup
    description:
    - The name of the port group for the VMKernel interface.
    required: true
    type: str

validate_certs:
    default: true
    description:
    - Allows connection when SSL certificates are not valid. Set to V(false) when certificates
      are not trusted.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_VALIDATE_CERTS)
      will be used instead.
    type: bool

enable_backup_nfc:
    default: false
    description:
    - Enable vSphere Backup NFC traffic on the VMKernel adapter.
    - This option is only allowed if the default TCP/IP stack is used.
    type: bool
    version_added: 4.2.0
    version_added_collection: community.vmware

enable_replication:
    default: false
    description:
    - Enable vSphere Replication traffic on the VMKernel adapter.
    - This option is only allowed if the default TCP/IP stack is used.
    type: bool

enable_provisioning:
    default: false
    description:
    - Enable Provisioning traffic on the VMKernel adapter.
    - This option is only allowed if the default TCP/IP stack is used.
    type: bool

enable_replication_nfc:
    default: false
    description:
    - Enable vSphere Replication NFC traffic on the VMKernel adapter.
    - This option is only allowed if the default TCP/IP stack is used.
    type: bool

Outputs

result:
  description: metadata about VMKernel name
  returned: always
  sample:
    changed: false
    device: vmk1
    ipv4: static
    ipv4_gw: No override
    ipv4_ip: 192.168.1.15
    ipv4_sm: 255.255.255.0
    msg: VMkernel Adapter already configured properly
    mtu: 9000
    services: vMotion
    switch: vDS
  type: dict