vmware_guest_network – Manage network adapters of specified virtual machine in given vCenter infrastructure
vmware_guest_network – Manage network adapters of specified virtual machine in given vCenter infrastructure
New in version 2.9.
Synopsis
- This module is used to add, reconfigure, remove network adapter of given virtual machine.
- All parameters and VMware object names are case sensitive.
Requirements
The below requirements are needed on the host that executes this module.
- python >= 2.6
- PyVmomi
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
cluster string |
The name of cluster where the virtual machine will run. This is a required parameter, if
| |
datacenter string |
Default: "ha-datacenter" |
The datacenter name to which virtual machine belongs to. |
esxi_hostname string |
The ESXi hostname where the virtual machine will run. This is a required parameter, if
| |
folder string |
Destination folder, absolute or relative path to find an existing guest. This is a required parameter, only if multiple VMs are found with same name. The folder should include the datacenter. ESXi server's datacenter is ha-datacenter. Examples: folder: /ha-datacenter/vm folder: ha-datacenter/vm folder: /datacenter1/vm folder: datacenter1/vm folder: /datacenter1/vm/folder1 folder: datacenter1/vm/folder1 folder: /folder1/datacenter1/vm folder: folder1/datacenter1/vm folder: /folder1/datacenter1/vm/folder2 | |
gather_network_info boolean |
|
If set to If set to
|
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 Environment variable support added in Ansible 2.6. | |
moid string |
Managed Object ID of the instance to manage if known, this is a unique identifier only within a single vCenter instance. This is required if | |
name string |
Name of the virtual machine. This is a required parameter, if parameter | |
networks list |
A list of network adapters.
If there are multiple network adapters with the same
Valid attributes are: - - - - - - - If set to If set to If set to - - - | |
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 Environment variable support added in Ansible 2.6.
| |
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 Environment variable support added in Ansible 2.6. |
proxy_host string added in 2.9 |
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 | |
proxy_port integer added in 2.9 |
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 | |
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 Environment variable support added in Ansible 2.6.
| |
uuid string |
UUID of the instance to gather info if known, this is VMware's unique identifier. This is a required parameter, if parameter | |
validate_certs boolean |
|
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 |
Notes
Note
- Tested on vSphere 6.0, 6.5 and 6.7
Examples
- name: Change network adapter settings of virtual machine
vmware_guest_network:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
validate_certs: no
name: test-vm
gather_network_info: false
networks:
- name: "VM Network"
state: new
manual_mac: "00:50:56:11:22:33"
- state: present
device_type: e1000e
manual_mac: "00:50:56:44:55:66"
- state: present
label: "Network adapter 3"
connected: false
- state: absent
mac: "00:50:56:44:55:77"
delegate_to: localhost
register: network_info
- name: Change network adapter settings of virtual machine using MoID
vmware_guest_network:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
validate_certs: no
moid: vm-42
gather_network_info: false
networks:
- state: absent
mac: "00:50:56:44:55:77"
delegate_to: localhost
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
network_data dictionary |
always |
metadata about the virtual machine's network adapter after managing them
Sample: {'0': {'label': 'Network Adapter 1', 'name': 'VM Network', 'device_type': 'E1000E', 'mac_addr': '00:50:56:89:dc:05', 'unit_number': 7, 'wake_onlan': False, 'allow_guest_ctl': True, 'connected': True, 'start_connected': True}} |
Status
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors
- Diane Wang (@Tomorrow9) <[email protected]>
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.9/modules/vmware_guest_network_module.html