community.vmware.vmware_dvs_portgroup module – Create or remove a Distributed vSwitch portgroup.
Note
This module is part of the community.vmware collection (version 1.18.2).
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_dvs_portgroup
.
Requirements
The below requirements are needed on the host that executes this module.
python >= 2.6
PyVmomi
Parameters
Parameter |
Comments |
---|---|
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. |
|
Dictionary which configures MAC learning for portgroup. |
|
The flag to allow flooding of unlearned MAC for ingress traffic. Choices:
|
|
The flag to indicate if source MAC address learning is allowed. Choices:
|
|
The maximum number of MAC addresses that can be learned. |
|
The default switching policy after MAC limit is exceeded. Choices:
|
|
Dictionary which configures the different security values for portgroup. Default: {“forged_transmits”: false, “mac_changes”: false, “promiscuous”: false} |
|
Indicates whether forged transmits are allowed. Choices:
|
|
Indicates whether mac changes are allowed. Choices:
|
|
Indicates whether promiscuous mode is allowed. Choices:
|
|
The number of ports the portgroup should contain. |
|
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: 443 |
|
Elastic port groups automatically increase or decrease the number of ports as needed. Only valid if port_binding is set to Will be Choices:
|
|
The type of port binding determines when ports in a port group are assigned to virtual machines. See VMware KB 1022312 https://kb.vmware.com/s/article/1022312 for more details. Choices:
|
|
Dictionary which configures the advanced policy settings for the portgroup. Default: {“block_override”: true, “ipfix_override”: false, “live_port_move”: false, “network_rp_override”: false, “port_config_reset_at_disconnect”: true, “security_override”: false, “shaping_override”: false, “traffic_filter_override”: false, “uplink_teaming_override”: false, “vendor_config_override”: false, “vlan_override”: false} |
|
Indicates if the block policy can be changed per port. Choices:
|
|
Indicates if the ipfix policy can be changed per port. Choices:
|
|
Indicates if a live port can be moved in or out of the portgroup. Choices:
|
|
Indicates if the network resource pool can be changed per port. Choices:
|
|
Indicates if the configuration of a port is reset automatically after disconnect. Choices:
|
|
Indicates if the security policy can be changed per port. Choices:
|
|
Indicates if the shaping policy can be changed per port. Choices:
|
|
Indicates if the traffic filter can be changed per port. Choices:
|
|
Indicates if the uplink teaming policy can be changed per port. Choices:
|
|
Indicates if the vendor config can be changed per port. Choices:
|
|
Indicates if the vlan can be changed per port. Choices:
|
|
The name of the portgroup that is to be created or deleted. |
|
See VMware KB 1022312 regarding portgroup types. Deprecated. Will be removed 2021-12-01. Choices:
|
|
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 |
|
Determines if the portgroup should be present or not. Choices:
|
|
The name of the distributed vSwitch the port group should be created on. |
|
Dictionary which configures the different teaming values for portgroup. Default: {“load_balance_policy”: “loadbalance_srcid”, “notify_switches”: true, “rolling_order”: false} |
|
List of active uplinks used for load balancing. |
|
Indicate whether or not the teaming policy is applied to inbound frames as well. Choices:
|
|
Network adapter teaming policy.
Choices:
|
|
Indicate whether or not to notify the physical switch if a link fails. Choices:
|
|
Indicate whether or not to use a rolling policy when restoring links. Choices:
|
|
List of standby uplinks used for failover. |
|
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:
|
|
The VLAN ID that should be configured with the portgroup, use 0 for no VLAN. If The valid If |
|
Indicates whether this is for a private VLAN or not. Mutually exclusive with Choices:
|
|
Indicates whether this is a VLAN trunk or not. Mutually exclusive with Choices:
|
Notes
Note
Tested on vSphere 7.0
All modules requires API write access and hence is not supported on a free ESXi license.
Examples
- name: Create vlan portgroup
community.vmware.vmware_dvs_portgroup:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
portgroup_name: vlan-123-portrgoup
switch_name: dvSwitch
vlan_id: 123
num_ports: 120
port_binding: static
state: present
delegate_to: localhost
- name: Create vlan trunk portgroup
community.vmware.vmware_dvs_portgroup:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
portgroup_name: vlan-trunk-portrgoup
switch_name: dvSwitch
vlan_id: 1-1000, 1005, 1100-1200
vlan_trunk: True
num_ports: 120
port_binding: static
state: present
delegate_to: localhost
- name: Create private vlan portgroup
vmware_dvs_portgroup:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
portgroup_name: private-vlan-portrgoup
switch_name: dvSwitch
vlan_id: 1001
vlan_private: True
num_ports: 120
port_binding: static
state: present
delegate_to: localhost
- name: Create no-vlan portgroup
community.vmware.vmware_dvs_portgroup:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
portgroup_name: no-vlan-portrgoup
switch_name: dvSwitch
vlan_id: 0
num_ports: 120
port_binding: static
state: present
delegate_to: localhost
- name: Create vlan portgroup with all security and port policies
community.vmware.vmware_dvs_portgroup:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
portgroup_name: vlan-123-portrgoup
switch_name: dvSwitch
vlan_id: 123
num_ports: 120
port_binding: static
state: present
network_policy:
promiscuous: true
forged_transmits: true
mac_changes: true
port_policy:
block_override: true
ipfix_override: true
live_port_move: true
network_rp_override: true
port_config_reset_at_disconnect: true
security_override: true
shaping_override: true
traffic_filter_override: true
uplink_teaming_override: true
vendor_config_override: true
vlan_override: true
delegate_to: localhost
Authors
Joseph Callen (@jcpowermac)
Philippe Dellaert (@pdellaert)