community.vmware.vmware_vswitch module – Manage a VMware Standard Switch to an ESXi host.
Note
This module is part of the community.vmware collection (version 3.11.1).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.vmware
.
To use it in a playbook, specify: community.vmware.vmware_vswitch
.
Synopsis
This module can be used to add, remove and update a VMware Standard Switch to an ESXi host.
Parameters
Parameter |
Comments |
---|---|
Manage the vSwitch using this ESXi host system. |
|
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 Environment variable support added in Ansible 2.6. |
|
MTU to configure on vSwitch. Default: |
|
A list of vmnic names or vmnic name to attach to vSwitch. Alias Default: |
|
Number of port to configure on vSwitch. Default: |
|
The password of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable Environment variable support added in Ansible 2.6. |
|
The port number of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable Environment variable support added in Ansible 2.6. Default: |
|
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 This feature depends on a version of pyvmomi greater than v6.7.1.2018.12 |
|
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 |
|
Network policy specifies layer 2 security settings for a portgroup such as promiscuous mode, where guest adapter listens to all the packets, MAC address changes and forged transmits. Dict which configures the different security values for portgroup. |
|
Indicates whether forged transmits are allowed. Choices:
|
|
Indicates whether mac changes are allowed. Choices:
|
|
Indicates whether promiscuous mode is allowed. Choices:
|
|
Add or remove the switch. Choices:
|
|
vSwitch name to add. Alias |
|
Dictionary which configures the different teaming values for portgroup. |
|
List of active adapters used for load balancing. All vmnics are used as active adapters if |
|
Indicate whether or not to use a failback when restoring links. Choices:
|
|
Network adapter teaming policy. Choices:
|
|
Network failure detection. Choices:
|
|
Indicate whether or not to notify the physical switch if a link fails. Choices:
|
|
List of standby adapters used for failover. All vmnics are used as active adapters if |
|
Dictionary which configures traffic shaping for the switch. |
|
Average bandwidth (kbit/s). |
|
Burst size (KB). |
|
Status of Traffic Shaping Policy. Choices:
|
|
Peak bandwidth (kbit/s). |
|
The username of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable Environment variable support added in Ansible 2.6. |
|
Allows connection when SSL certificates are not valid. Set to If the value is not specified in the task, the value of environment variable Environment variable support added in Ansible 2.6. If set to Choices:
|
Notes
Note
All modules requires API write access and hence is not supported on a free ESXi license.
Examples
- name: Add a VMware vSwitch
community.vmware.vmware_vswitch:
hostname: '{{ esxi_hostname }}'
username: '{{ esxi_username }}'
password: '{{ esxi_password }}'
switch: vswitch_name
nics: vmnic_name
mtu: 9000
delegate_to: localhost
- name: Add a VMware vSwitch without any physical NIC attached
community.vmware.vmware_vswitch:
hostname: '{{ esxi_hostname }}'
username: '{{ esxi_username }}'
password: '{{ esxi_password }}'
switch: vswitch_0001
mtu: 9000
delegate_to: localhost
- name: Add a VMware vSwitch with multiple NICs
community.vmware.vmware_vswitch:
hostname: '{{ esxi_hostname }}'
username: '{{ esxi_username }}'
password: '{{ esxi_password }}'
switch: vmware_vswitch_0004
nics:
- vmnic1
- vmnic2
mtu: 9000
delegate_to: localhost
- name: Add a VMware vSwitch to a specific host system
community.vmware.vmware_vswitch:
hostname: '{{ esxi_hostname }}'
username: '{{ esxi_username }}'
password: '{{ esxi_password }}'
esxi_hostname: DC0_H0
switch_name: vswitch_001
nic_name: vmnic0
mtu: 9000
delegate_to: localhost
- name: Add a VMware vSwitch to a specific host system with Promiscuous Mode Enabled
community.vmware.vmware_vswitch:
hostname: '{{ esxi_hostname }}'
username: '{{ esxi_username }}'
password: '{{ esxi_password }}'
esxi_hostname: DC0_H0
switch_name: vswitch_001
nic_name: vmnic0
mtu: 9000
security:
promiscuous_mode: true
delegate_to: localhost
- name: Add a VMware vSwitch to a specific host system with active/standby teaming
community.vmware.vmware_vswitch:
hostname: '{{ esxi_hostname }}'
username: '{{ esxi_username }}'
password: '{{ esxi_password }}'
esxi_hostname: DC0_H0
switch_name: vswitch_001
nic_name:
- vmnic0
- vmnic1
teaming:
active_adapters:
- vmnic0
standby_adapters:
- vmnic1
delegate_to: localhost
- name: Add a VMware vSwitch to a specific host system with traffic shaping
community.vmware.vmware_vswitch:
hostname: '{{ esxi_hostname }}'
username: '{{ esxi_username }}'
password: '{{ esxi_password }}'
esxi_hostname: DC0_H0
switch_name: vswitch_001
nic_name:
- vmnic0
- vmnic1
traffic_shaping:
enabled: true
average_bandwidth: 100000
peak_bandwidth: 100000
burst_size: 102400
delegate_to: localhost
- name: Delete a VMware vSwitch in a specific host system
community.vmware.vmware_vswitch:
hostname: '{{ esxi_hostname }}'
username: '{{ esxi_username }}'
password: '{{ esxi_password }}'
esxi_hostname: DC0_H0
switch_name: vswitch_001
state: absent
delegate_to: localhost
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
information about performed operation Returned: always Sample: |