community / community.vmware / 2.10.4 / module / vmware_portgroup Create a VMware portgroup Authors: Joseph Callen (@jcpowermac), Russell Teague (@mtnbikenc), Abhijeet Kasurde (@Akasurde), Christian Kotte (@ckotte)community.vmware.vmware_portgroup (2.10.4) — module
Install with ansible-galaxy collection install community.vmware:==2.10.4
collections: - name: community.vmware version: 2.10.4
Create a VMware Port Group on a VMware Standard Switch (vSS) for given ESXi host(s) or hosts of given cluster.
- 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
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 hosts: aliases: - esxi_hostname description: - List of name of host or hosts on which portgroup needs to be added. - This option is required if C(cluster_name) is not specified. elements: str type: list state: choices: - present - absent default: present description: - Determines if the portgroup should be present or not. type: str switch: aliases: - switch_name - vswitch description: - vSwitch to modify. required: true type: str teaming: aliases: - teaming_policy description: - Dictionary which configures the different teaming values for portgroup. required: false suboptions: active_adapters: description: - List of active adapters used for load balancing. - All vmnics are used as active adapters if C(active_adapters) and C(standby_adapters) are not defined. elements: str type: list failback: description: Indicate whether or not to use a failback when restoring links. type: bool load_balancing: aliases: - load_balance_policy choices: - loadbalance_ip - loadbalance_srcmac - loadbalance_srcid - failover_explicit - None description: - Network adapter teaming policy. type: str network_failure_detection: choices: - link_status_only - beacon_probing description: Network failure detection. type: str notify_switches: description: Indicate whether or not to notify the physical switch if a link fails. type: bool standby_adapters: description: - List of standby adapters used for failover. - All vmnics are used as active adapters if C(active_adapters) and C(standby_adapters) are not defined. elements: str type: list type: dict vlan_id: aliases: - vlan default: 0 description: - VLAN ID to assign to portgroup. - Set to 0 (no VLAN tagging) by default. required: false type: int 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 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 security: aliases: - security_policy - network_policy description: - 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. required: false suboptions: forged_transmits: description: Indicates whether forged transmits are allowed. type: bool mac_changes: description: Indicates whether mac changes are allowed. type: bool promiscuous_mode: description: Indicates whether promiscuous mode is allowed. type: bool type: dict 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 portgroup: aliases: - portgroup_name description: - Portgroup name to add. required: true 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 cluster_name: aliases: - cluster description: - Name of cluster name for host membership. - Portgroup will be created on all hosts of the given cluster. - This option is required if C(hosts) is not specified. 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 traffic_shaping: description: - Dictionary which configures traffic shaping for the switch. required: false suboptions: average_bandwidth: description: Average bandwidth (kbit/s). type: int burst_size: description: Burst size (KB). type: int enabled: description: Status of Traffic Shaping Policy. type: bool peak_bandwidth: description: Peak bandwidth (kbit/s). type: int type: dict
result: description: metadata about the portgroup returned: always sample: esxi01.example.com: changed: true failback: No override failover_active: No override failover_standby: No override failure_detection: No override load_balancing: No override msg: Port Group added notify_switches: No override portgroup: vMotion sec_forged_transmits: false sec_mac_changes: false sec_promiscuous_mode: false traffic_shaping: No override vlan_id: 33 vswitch: vSwitch1 type: dict