ansible / ansible.builtin / v2.9.24 / module / vmware_guest_network Manage network adapters of specified virtual machine in given vCenter infrastructure | "added in version" 2.9 of ansible.builtin" Authors: Diane Wang (@Tomorrow9) <dianew@vmware.com> preview | supported by communityansible.builtin.vmware_guest_network (v2.9.24) — module
pip
Install with pip install ansible==2.9.24
This module is used to add, reconfigure, remove network adapter of given virtual machine.
All parameters and VMware object names are case sensitive.
- 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
moid: description: - 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 C(name) or C(uuid) is not supplied. type: str name: description: - Name of the virtual machine. - This is a required parameter, if parameter C(uuid) or C(moid) is not supplied. type: str 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 C(VMWARE_PORT) will be used instead. - Environment variable support added in Ansible 2.6. type: int uuid: description: - UUID of the instance to gather info if known, this is VMware's unique identifier. - This is a required parameter, if parameter C(name) or C(moid) is not supplied. type: str folder: description: - 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' type: str cluster: description: - The name of cluster where the virtual machine will run. - This is a required parameter, if C(esxi_hostname) is not set. - C(esxi_hostname) and C(cluster) are mutually exclusive parameters. type: str 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 C(VMWARE_HOST) will be used instead. - Environment variable support added in Ansible 2.6. type: str networks: description: - A list of network adapters. - C(mac) or C(label) or C(device_type) is required to reconfigure or remove an existing network adapter. - If there are multiple network adapters with the same C(device_type), you should set C(label) or C(mac) to match one of them, or will apply changes on all network adapters with the C(device_type) specified. - C(mac), C(label), C(device_type) is the order of precedence from greatest to least if all set. - 'Valid attributes are:' - ' - C(mac) (string): MAC address of the existing network adapter to be reconfigured or removed.' - ' - C(label) (string): Label of the existing network adapter to be reconfigured or removed, e.g., "Network adapter 1".' - ' - C(device_type) (string): Valid virtual network device types are: C(e1000), C(e1000e), C(pcnet32), C(vmxnet2), C(vmxnet3) (default), C(sriov). Used to add new network adapter, reconfigure or remove the existing network adapter with this type. If C(mac) and C(label) not specified or not find network adapter by C(mac) or C(label) will use this parameter.' - ' - C(name) (string): Name of the portgroup or distributed virtual portgroup for this interface. When specifying distributed virtual portgroup make sure given C(esxi_hostname) or C(cluster) is associated with it.' - ' - C(vlan) (integer): VLAN number for this interface.' - ' - C(dvswitch_name) (string): Name of the distributed vSwitch. This value is required if multiple distributed portgroups exists with the same name.' - ' - C(state) (string): State of the network adapter.' - ' If set to C(present), then will do reconfiguration for the specified network adapter.' - ' If set to C(new), then will add the specified network adapter.' - ' If set to C(absent), then will remove this network adapter.' - ' - C(manual_mac) (string): Manual specified MAC address of the network adapter when creating, or reconfiguring. If not specified when creating new network adapter, mac address will be generated automatically. When reconfigure MAC address, VM should be in powered off state.' - ' - C(connected) (bool): Indicates that virtual network adapter connects to the associated virtual machine.' - ' - C(start_connected) (bool): Indicates that virtual network adapter starts with associated virtual machine powers on.' type: list 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 C(VMWARE_PASSWORD) will be used instead. - Environment variable support added in Ansible 2.6. 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 C(VMWARE_USER) will be used instead. - Environment variable support added in Ansible 2.6. type: str datacenter: default: ha-datacenter description: - The datacenter name to which virtual machine belongs to. 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 C(VMWARE_PROXY_HOST) will be used instead. - This feature depends on a version of pyvmomi greater than v6.7.1.2018.12 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 C(VMWARE_PROXY_PORT) will be used instead. required: false type: int esxi_hostname: description: - The ESXi hostname where the virtual machine will run. - This is a required parameter, if C(cluster) is not set. - C(esxi_hostname) and C(cluster) are mutually exclusive parameters. type: str validate_certs: default: true description: - Allows connection when SSL certificates are not valid. Set to C(false) when certificates are not trusted. - If the value is not specified in the task, the value of environment variable C(VMWARE_VALIDATE_CERTS) will be used instead. - Environment variable support added in Ansible 2.6. - If set to C(true), please make sure Python >= 2.7.9 is installed on the given machine. type: bool gather_network_info: aliases: - gather_network_facts default: false description: - If set to C(True), return settings of all network adapters, other parameters are ignored. - If set to C(False), will add, reconfigure or remove network adapters according to the parameters in C(networks). type: bool
network_data: description: metadata about the virtual machine's network adapter after managing them returned: always sample: '0': allow_guest_ctl: true connected: true device_type: E1000E label: Network Adapter 1 mac_addr: 00:50:56:89:dc:05 name: VM Network start_connected: true unit_number: 7 wake_onlan: false type: dict