community.vmware.vmware_guest_network module – Manage network adapters of specified virtual machine in given vCenter infrastructure
Note
This module is part of the community.vmware collection (version 4.8.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_guest_network
.
Synopsis
This module is used to add, reconfigure, remove network adapter of given virtual machine.
Parameters
Parameter |
Comments |
---|---|
Allows the guest OS to change the MTU on a SR-IOV network adapter. This option is only compatible for SR-IOV network adapters. Choices:
|
|
Name of cluster where VM belongs to. |
|
If NIC should be connected to the network. Choices:
|
|
Datacenter the VM belongs to. Default: |
|
Type of virtual network device. Valid choices are - Default: |
|
Enable Universal Pass-through (UPT). Only compatible with the Choices:
|
|
The hostname of the ESXi host where the VM belongs to. |
|
Folder location of given VM, this is only required when there’s multiple VM’s with the same name. |
|
Force adapter creation even if an existing adapter is attached to the same network. Choices:
|
|
Return information about current guest network adapters. Choices:
|
|
Enables guest control over whether the connectable device is connected. Choices:
|
|
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 |
|
Label of the NIC that should be altered. Alter the name of the network adapter. |
|
MAC address of the NIC that should be altered, if a MAC address is not supplied a new nic will be created. Required when |
|
Name of network in vSphere. |
|
The password of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable |
|
If set, specifies the PCI ID of the physical function to use as backing for a SR-IOV network adapter. This option is only compatible for SR-IOV network adapters. |
|
The port number of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable 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 |
|
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 |
|
The PVRDMA device protocol used. Valid choices are - This parameter is only used on the VM with hardware version >=14 and <= 19. |
|
If NIC should be connected to network on startup. Choices:
|
|
NIC state. When When Choices:
|
|
Name of the (dv)switch for destination network, this is only required for dvswitches. |
|
Whether to use the VMware instance UUID rather than the BIOS UUID. Choices:
|
|
The username of the vSphere vCenter or ESXi server. If the value is not specified in the task, the value of environment variable |
|
Allows connection when SSL certificates are not valid. Set to If the value is not specified in the task, the value of environment variable Choices:
|
|
If set, specifies the PCI ID of the physical function to use as backing for a SR-IOV network adapter. This option is only compatible for SR-IOV network adapters. |
|
VLAN id associated with the network. |
|
Enable wake on LAN. Choices:
|
Notes
Note
For backwards compatibility network_data is returned when using the gather_network_info parameter
All modules requires API write access and hence is not supported on a free ESXi license.
All variables and VMware object names are case sensitive.
Examples
- name: change network for 00:50:56:11:22:33 on vm01.domain.fake
community.vmware.vmware_guest_network:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: vm01.domain.fake
mac_address: 00:50:56:11:22:33
network_name: admin-network
state: present
- name: add a nic on network with vlan id 2001 for 422d000d-2000-ffff-0000-b00000000000
community.vmware.vmware_guest_network:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
uuid: 422d000d-2000-ffff-0000-b00000000000
vlan_id: 2001
- name: remove nic with mac 00:50:56:11:22:33 from vm01.domain.fake
community.vmware.vmware_guest_network:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
mac_address: 00:50:56:11:22:33
name: vm01.domain.fake
state: absent
- name: add multiple nics to vm01.domain.fake
community.vmware.vmware_guest_network:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
name: vm01.domain.fake
state: present
vlan_id: "{{ item.vlan_id | default(omit) }}"
network_name: "{{ item.network_name | default(omit) }}"
connected: "{{ item.connected | default(omit) }}"
loop:
- vlan_id: 2000
connected: false
- network_name: guest-net
connected: true
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
For backwards compatibility, metadata about the virtual machine network adapters Returned: when using gather_network_info parameter Sample: |
|
metadata about the virtual machine network adapters Returned: always Sample: |