community.vmware.vmware_portgroup module – Create a VMware portgroup
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_portgroup
.
Synopsis
Create a VMware Port Group on a VMware Standard Switch (vSS) for given ESXi host(s) or hosts of given cluster.
Parameters
Parameter |
Comments |
---|---|
Name of cluster name for host membership. Portgroup will be created on all hosts of the given cluster. This option is required if |
|
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. |
|
List of name of host or hosts on which portgroup needs to be added. This option is required if |
|
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: |
|
Portgroup name to add. |
|
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:
|
|
Determines if the portgroup should be present or not. Choices:
|
|
vSwitch to modify. |
|
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:
|
|
VLAN ID to assign to portgroup. Set to 0 (no VLAN tagging) by default. Default: |
Notes
Note
All modules requires API write access and hence is not supported on a free ESXi license.
Examples
- name: Add Management Network VM Portgroup
community.vmware.vmware_portgroup:
hostname: "{{ esxi_hostname }}"
username: "{{ esxi_username }}"
password: "{{ esxi_password }}"
switch: "{{ vswitch_name }}"
portgroup: "{{ portgroup_name }}"
vlan_id: "{{ vlan_id }}"
delegate_to: localhost
- name: Add Portgroup with Promiscuous Mode Enabled
community.vmware.vmware_portgroup:
hostname: "{{ esxi_hostname }}"
username: "{{ esxi_username }}"
password: "{{ esxi_password }}"
switch: "{{ vswitch_name }}"
portgroup: "{{ portgroup_name }}"
security:
promiscuous_mode: true
delegate_to: localhost
- name: Add Management Network VM Portgroup to specific hosts
community.vmware.vmware_portgroup:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
hosts: [esxi_hostname_one]
switch: "{{ vswitch_name }}"
portgroup: "{{ portgroup_name }}"
vlan_id: "{{ vlan_id }}"
delegate_to: localhost
- name: Add Management Network VM Portgroup to all hosts in a cluster
community.vmware.vmware_portgroup:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ cluster_name }}"
switch: "{{ vswitch_name }}"
portgroup: "{{ portgroup_name }}"
vlan_id: "{{ vlan_id }}"
delegate_to: localhost
- name: Remove Management Network VM Portgroup to all hosts in a cluster
community.vmware.vmware_portgroup:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ cluster_name }}"
switch: "{{ vswitch_name }}"
portgroup: "{{ portgroup_name }}"
vlan_id: "{{ vlan_id }}"
state: absent
delegate_to: localhost
- name: Add Portgroup with all settings defined
community.vmware.vmware_portgroup:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: "{{ inventory_hostname }}"
switch: "{{ vswitch_name }}"
portgroup: "{{ portgroup_name }}"
vlan_id: 10
security:
promiscuous_mode: false
mac_changes: false
forged_transmits: false
traffic_shaping:
enabled: true
average_bandwidth: 100000
peak_bandwidth: 100000
burst_size: 102400
teaming:
load_balancing: failover_explicit
network_failure_detection: link_status_only
notify_switches: true
failback: true
active_adapters:
- vmnic0
standby_adapters:
- vmnic1
delegate_to: localhost
register: teaming_result
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
metadata about the portgroup Returned: always Sample: |