On this page
vmware_vmkernel – Manages a VMware VMkernel Adapter of an ESXi host
New in version 2.0.
Synopsis
- 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.
 
Requirements
The below requirements are needed on the host that executes this module.
- python >= 2.6
 - PyVmomi
 
Parameters
| Parameter | Choices/Defaults | Comments | 
|---|---|---|
| device
        
        -
        
       
        added in 2.8
         | 
      
        
        Search VMkernel adapter by device name.
        
       
        The parameter is required only in case of  type is set to dhcp.
        | 
     |
| dvswitch_name
        
        string
        
       
        added in 2.8
         | 
      
        
        The name of the vSphere Distributed Switch (vDS) where to add the VMKernel interface.
        
       
        Required parameter only if  
       state is set to present.
       
        Optional parameter from version 2.8 and onwards.
        
       aliases: dvswitch  | 
     |
| enable_ft
        
        boolean
         | 
      
       
  | 
      
        
        Enable Fault Tolerance traffic on the VMKernel adapter.
        
       
        This option is only allowed if the default TCP/IP stack is used.
         | 
     
| enable_mgmt
        
        boolean
         | 
      
       
  | 
      
        
        Enable Management traffic on the VMKernel adapter.
        
       
        This option is only allowed if the default TCP/IP stack is used.
         | 
     
| enable_provisioning
        
        boolean
        
       
        added in 2.8
         | 
      
       
  | 
      
        
        Enable Provisioning traffic on the VMKernel adapter.
        
       
        This option is only allowed if the default TCP/IP stack is used.
         | 
     
| enable_replication
        
        boolean
        
       
        added in 2.8
         | 
      
       
  | 
      
        
        Enable vSphere Replication traffic on the VMKernel adapter.
        
       
        This option is only allowed if the default TCP/IP stack is used.
         | 
     
| enable_replication_nfc
        
        boolean
        
       
        added in 2.8
         | 
      
       
  | 
      
        
        Enable vSphere Replication NFC traffic on the VMKernel adapter.
        
       
        This option is only allowed if the default TCP/IP stack is used.
         | 
     
| enable_vmotion
        
        boolean
         | 
      
       
  | 
      
        
        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.
         | 
     
| enable_vsan
        
        boolean
         | 
      
       
  | 
      
        
        Enable VSAN traffic on the VMKernel adapter.
        
       
        This option is only allowed if the default TCP/IP stack is used.
         | 
     
| esxi_hostname
        
        - / required
        
       
        added in 2.5
         | 
      
        
        Name of ESXi host to which VMKernel is to be managed.
        
       
        From version 2.5 onwards, this parameter is required.
         | 
     |
| hostname
        
        string
         | 
      
        
        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  
       VMWARE_HOST will be used instead.
       
        Environment variable support added in Ansible 2.6.
         | 
     |
| ip_address
        
        -
         | 
      
        
        The IP Address for the VMKernel interface.
        
       
        Use  
       network parameter with ip_address instead.
       
        Deprecated option, will be removed in version 2.9.
         | 
     |
| mtu
        
        -
         | 
      Default: 
        1500
         | 
      
        
        The MTU for the VMKernel interface.
        
       
        The default value of 1500 is valid from version 2.5 and onwards.
         | 
     
| network
        
        dictionary
        
       
        added in 2.5
         | 
      Default: 
        {"tcpip_stack": "default", "type": "static"}
         | 
      
        
        A dictionary of network details.
        
       
        The following parameter is required:
        
       
        -  
       type (string): Type of IP assignment (either dhcp or static).
       
        The following parameters are required in case of  
       type is set to static:
       
        -  
       ip_address (string): Static IP address (implies type: static).
       
        -  
       subnet_mask (string): Static netmask required for ip_address.
       
        The following parameter is optional in case of  
       type is set to static:
       
        -  
       default_gateway (string): Default gateway (Override default gateway for this adapter).
       
        The following parameter is optional:
        
       
        -  tcpip_stack (string): The TCP/IP stack for the VMKernel interface. Can be default, provisioning, vmotion, or vxlan. (default: default)
        | 
     
| password
        
        string
         | 
      
        
        The password of the vSphere vCenter or ESXi server.
        
       
        If the value is not specified in the task, the value of environment variable  
       VMWARE_PASSWORD will be used instead.
       
        Environment variable support added in Ansible 2.6.
        
       aliases: pass, pwd  | 
     |
| port
        
        integer
        
       
        added in 2.5
         | 
      Default: 
        443
         | 
      
        
        The port number of the vSphere vCenter or ESXi server.
        
       
        If the value is not specified in the task, the value of environment variable  
       VMWARE_PORT will be used instead.
       
        Environment variable support added in Ansible 2.6.
         | 
     
| portgroup_name
        
        - / required
         | 
      
        
        The name of the port group for the VMKernel interface.
        
       aliases: portgroup  | 
     |
| state
        
        -
        
       
        added in 2.5
         | 
      
       
  | 
      
        
        If set to  
       present, the VMKernel adapter will be created with the given specifications.
       
        If set to  
       absent, the VMKernel adapter will be removed.
       
        If set to  present and VMKernel adapter exists, the configurations will be updated.
        | 
     
| subnet_mask
        
        -
         | 
      
        
        The Subnet Mask for the VMKernel interface.
        
       
        Use  
       network parameter with subnet_mask instead.
       
        Deprecated option, will be removed in version 2.9.
         | 
     |
| username
        
        string
         | 
      
        
        The username of the vSphere vCenter or ESXi server.
        
       
        If the value is not specified in the task, the value of environment variable  
       VMWARE_USER will be used instead.
       
        Environment variable support added in Ansible 2.6.
        
       aliases: admin, user  | 
     |
| validate_certs
        
        boolean
         | 
      
       
  | 
      
        
        Allows connection when SSL certificates are not valid. Set to  
       false when certificates are not trusted.
       
        If the value is not specified in the task, the value of environment variable  
       VMWARE_VALIDATE_CERTS will be used instead.
       
        Environment variable support added in Ansible 2.6.
        
       
        If set to  yes, please make sure Python >= 2.7.9 is installed on the given machine.
        | 
     
| vswitch_name
        
        string
         | 
      
        
        The name of the vSwitch where to add the VMKernel interface.
        
       
        Required parameter only if  
       state is set to present.
       
        Optional parameter from version 2.5 and onwards.
        
       aliases: vswitch  | 
     
Notes
Note
- The option 
deviceneed to be used with DHCP because otherwise it’s not possible to check if a VMkernel device is already present - You can only change from DHCP to static, and vSS to vDS, or vice versa, in one step, without creating a new device, with 
devicespecified. - You can only create the VMKernel adapter on a vDS if authenticated to vCenter and not if authenticated to ESXi.
 - Tested on vSphere 5.5 and 6.5
 
Examples
-  name: Add Management vmkernel port using static network type
   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
-  name: Add Management vmkernel port using DHCP network type
   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
-  name: Change IP allocation from static to dhcp
   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
-  name: Delete VMkernel port
   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
-  name: Add Management vmkernel port to Distributed Switch
   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
-  name: Add vMotion vmkernel port with vMotion TCP/IP stack
   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
  Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Returned | Description | 
|---|---|---|
| result
        
        dictionary
         | 
      always | 
        
        metadata about VMKernel name
         Sample:
        
       
        {'changed': False, 'msg': 'VMkernel Adapter already configured properly', 'device': 'vmk1', 'ipv4': 'static', 'ipv4_gw': 'No override', 'ipv4_ip': '192.168.1.15', 'ipv4_sm': '255.255.255.0', 'mtu': 9000, 'services': 'vMotion', 'switch': 'vDS'}
         | 
     
Status
- This module is not guaranteed to have a backwards compatible interface. [preview]
 - This module is maintained by the Ansible Community. [community]
 
Authors
- Joseph Callen (@jcpowermac)
 - Russell Teague (@mtnbikenc)
 - Abhijeet Kasurde (@Akasurde)
 - Christian Kotte (@ckotte)
 
Hint
If you notice any issues in this documentation you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
 https://docs.ansible.com/ansible/2.8/modules/vmware_vmkernel_module.html