vmware_portgroup – Create a VMware portgroup
vmware_portgroup – Create a VMware portgroup
New in version 2.0.
Synopsis
- Create a VMware portgroup on given host/s or hosts of given cluster
Requirements
The below requirements are needed on the host that executes this module.
- python >= 2.6
- PyVmomi
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
cluster_name - added in 2.5 |
Name of cluster name for host membership. Portgroup will be created on all hosts of the given cluster. This option is required if | |
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 version 2.6. | |
hosts - added in 2.5 |
List of name of host or hosts on which portgroup needs to be added. This option is required if
| |
network_policy - added in 2.2 |
Default: {"forged_transmits": false, "mac_changes": false, "promiscuous_mode": false} |
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. Valid attributes are: - - - |
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 version 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 version 2.6. |
portgroup_name - / required |
Portgroup name to add. | |
state - added in 2.5 |
|
Determines if the portgroup should be present or not. |
switch_name - / required |
vSwitch to modify. | |
teaming_policy - added in 2.6 |
Default: {"inbound_policy": false, "load_balance_policy": "loadbalance_srcid", "notify_switches": true, "rolling_order": false} |
Dictionary which configures the different teaming values for portgroup. Valid attributes are: - - choices: [ loadbalance_ip, loadbalance_srcmac, loadbalance_srcid, failover_explicit ] - - - |
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 version 2.6.
| |
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 version 2.6. If set to |
vlan_id - / required |
VLAN ID to assign to portgroup. |
Notes
Note
- Tested on vSphere 5.5, 6.5
Examples
- name: Add Management Network VM Portgroup
vmware_portgroup:
hostname: "{{ esxi_hostname }}"
username: "{{ esxi_username }}"
password: "{{ esxi_password }}"
switch_name: "{{ vswitch_name }}"
portgroup_name: "{{ portgroup_name }}"
vlan_id: "{{ vlan_id }}"
delegate_to: localhost
- name: Add Portgroup with Promiscuous Mode Enabled
vmware_portgroup:
hostname: "{{ esxi_hostname }}"
username: "{{ esxi_username }}"
password: "{{ esxi_password }}"
switch_name: "{{ vswitch_name }}"
portgroup_name: "{{ portgroup_name }}"
network_policy:
promiscuous_mode: True
delegate_to: localhost
- name: Add Management Network VM Portgroup to specific hosts
vmware_portgroup:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
hosts: [esxi_hostname_one]
switch_name: "{{ vswitch_name }}"
portgroup_name: "{{ portgroup_name }}"
vlan_id: "{{ vlan_id }}"
delegate_to: localhost
- name: Add Management Network VM Portgroup to all hosts in a cluster
vmware_portgroup:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ cluster_name }}"
switch_name: "{{ vswitch_name }}"
portgroup_name: "{{ portgroup_name }}"
vlan_id: "{{ vlan_id }}"
delegate_to: localhost
- name: Remove Management Network VM Portgroup to all hosts in a cluster
vmware_portgroup:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
cluster_name: "{{ cluster_name }}"
switch_name: "{{ vswitch_name }}"
portgroup_name: "{{ portgroup_name }}"
vlan_id: "{{ vlan_id }}"
state: absent
delegate_to: localhost
- name: Add Portgroup with teaming policy
vmware_portgroup:
hostname: "{{ esxi_hostname }}"
username: "{{ esxi_username }}"
password: "{{ esxi_password }}"
switch_name: "{{ vswitch_name }}"
portgroup_name: "{{ portgroup_name }}"
teaming_policy:
load_balance_policy: 'failover_explicit'
inbound_policy: True
delegate_to: localhost
register: teaming_result
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
result dictionary |
always |
metadata about the portgroup
Sample: {'esxi01.example.com': {'portgroup_name': 'pg0010', 'switch_name': 'vswitch_0001', 'vlan_id': 1}} |
Status
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors
- Joseph Callen (@jcpowermac)
- Russell Teague (@mtnbikenc)
- Abhijeet Kasurde (@Akasurde) <[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.7/modules/vmware_portgroup_module.html