community.vmware.vmware_dvs_host (4.2.0) — module

Add or remove a host from distributed virtual switch

Authors: Joseph Callen (@jcpowermac), Abhijeet Kasurde (@Akasurde), Joseph Andreatta (@vmwjoseph)

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

Manage a host system from distributed virtual switch.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add Host to dVS
  community.vmware.vmware_dvs_host:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    esxi_hostname: '{{ esxi_hostname }}'
    switch_name: dvSwitch
    vmnics:
        - vmnic0
        - vmnic1
    state: present
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add vmnics to LAGs
  community.vmware.vmware_dvs_host:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    esxi_hostname: '{{ esxi_hostname }}'
    switch_name: dvSwitch
    lag_uplinks:
        - lag: lag1
          vmnics:
              - vmnic0
              - vmnic1
        - lag: lag2
          vmnics:
              - vmnic2
              - vmnic3
    state: present
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add Host to dVS/enable learnswitch (https://labs.vmware.com/flings/learnswitch)
  community.vmware.vmware_dvs_host:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    esxi_hostname: '{{ esxi_hostname }}'
    switch_name: dvSwitch
    vendor_specific_config:
        - key: com.vmware.netoverlay.layer1
          value: learnswitch
    vmnics:
        - vmnic0
        - vmnic1
    state: present
  delegate_to: localhost

Inputs

    
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 the host should be present or absent attached to the vSwitch.
    type: str

vmnics:
    description:
    - The ESXi hosts vmnics to use with the Distributed vSwitch.
    - If unset, the current non-LAG uplinks will be kept.
    - To remove all non-LAG uplinks, use the empty list V([]).
    elements: str
    required: false
    type: list

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

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

lag_uplinks:
    description:
    - The ESXi hosts vmnics to use with specific LAGs.
    - If unset, the current LAG uplinks will be kept.
    - If set, LAG uplinks will be set to I(exactly) this list. So you always have to define
      the complete LAG uplink configuration; if you don't, you might loose LAG uplinks.
    - To remove all LAG uplinks, use the empty list V([]).
    elements: dict
    required: false
    suboptions:
      lag:
        description:
        - Name of the LAG.
        required: true
        type: str
      vmnics:
        default: []
        description:
        - The ESXi hosts vmnics to use with the LAG.
        elements: str
        required: false
        type: list
    type: list

switch_name:
    description:
    - The name of the Distributed vSwitch.
    required: true
    type: str

esxi_hostname:
    description:
    - The ESXi hostname.
    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

vendor_specific_config:
    description:
    - List of key, value dictionaries for the Vendor Specific Configuration.
    elements: dict
    required: false
    suboptions:
      key:
        description:
        - Key of setting.
        required: true
        type: str
      value:
        description:
        - Value of setting.
        required: true
        type: str
    type: list