community / community.vmware / 4.2.0 / module / vmware_dvswitch Create or remove a Distributed Switch Authors: Joseph Callen (@jcpowermac), Abhijeet Kasurde (@Akasurde), Christian Kotte (@ckotte)community.vmware.vmware_dvswitch (4.2.0) — module
Install with ansible-galaxy collection install community.vmware:==4.2.0
collections: - name: community.vmware version: 4.2.0
This module can be used to create, remove a Distributed Switch.
- name: Create dvSwitch community.vmware.vmware_dvswitch: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: '{{ datacenter }}' switch: dvSwitch version: 6.0.0 mtu: 9000 uplink_quantity: 2 discovery_protocol: lldp discovery_operation: both state: present delegate_to: localhost
- name: Create dvSwitch with all options community.vmware.vmware_dvswitch: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: '{{ datacenter }}' switch: dvSwitch version: 6.5.0 mtu: 9000 uplink_quantity: 2 uplink_prefix: 'Uplink_' discovery_protocol: cdp discovery_operation: both multicast_filtering_mode: snooping health_check: vlan_mtu: true vlan_mtu_interval: 1 teaming_failover: true teaming_failover_interval: 1 net_flow: collector_ip: 192.168.10.50 collector_port: 50034 observation_domain_id: 0 active_flow_timeout: 60 idle_flow_timeout: 15 sampling_rate: 4096 internal_flows_only: false state: present delegate_to: localhost
- name: Delete dvSwitch community.vmware.vmware_dvswitch: hostname: '{{ vcenter_hostname }}' username: '{{ vcenter_username }}' password: '{{ vcenter_password }}' datacenter: '{{ datacenter }}' switch: dvSwitch state: absent delegate_to: localhost
mtu: default: 1500 description: - The switch maximum transmission unit. - Required if O(state=present). - Accepts value between 1280 to 9000 (both inclusive). type: int 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 E(VMWARE_PORT) will be used instead. type: int state: choices: - present - absent default: present description: - If set to V(present) and the Distributed Switch does not exist, the Distributed Switch will be created. - If set to V(absent) and the Distributed Switch exists, the Distributed Switch will be deleted. type: str folder: description: - Destination folder, absolute path to place dvswitch in. - The folder should include the datacenter. - This parameter is case sensitive. - Required if O(datacenter) is not provided. - Mutually exclusive with O(datacenter) parameter. - 'Examples:' - ' folder: /datacenter1/network' - ' folder: datacenter1/network' - ' folder: /datacenter1/network/folder1' - ' folder: datacenter1/network/folder1' - ' folder: /folder1/datacenter1/network' - ' folder: folder1/datacenter1/network' - ' folder: /folder1/datacenter1/network/folder2' required: false type: str contact: description: - Dictionary which configures administrator contact name and description for the Distributed Switch. suboptions: description: description: Description or other details. type: str name: description: Administrator name. type: str type: dict 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 E(VMWARE_HOST) will be used instead. type: str net_flow: default: active_flow_timeout: 60 collector_port: 0 idle_flow_timeout: 15 internal_flows_only: false observation_domain_id: 0 sampling_rate: 4096 description: - Dictionary which configures the Net Flow for the Distributed Switch. suboptions: active_flow_timeout: default: 60 description: The time, in seconds, to wait before sending information after the flow is initiated. type: int collector_ip: description: The IP Address (IPv4 or IPv6) of the NetFlow collector. type: str collector_port: default: 0 description: The Port of the NetFlow collector. type: int idle_flow_timeout: default: 15 description: The time, in seconds, to wait before sending information after the flow is initiated. type: int internal_flows_only: default: false description: If True, data on network activity between vms on the same host will be collected only. type: bool observation_domain_id: default: 0 description: Identifies the information related to the switch. type: int sampling_rate: default: 4096 description: - The portion of data that the switch collects. - The sampling rate represents the number of packets that NetFlow drops after every collected packet. - If the rate is 0, NetFlow samples every packet, that is, collect one packet and drop none. - If the rate is 1, NetFlow samples a packet and drops the next one, and so on. type: int type: dict 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 E(VMWARE_PASSWORD) will be used instead. 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 E(VMWARE_USER) will be used instead. 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 E(VMWARE_PROXY_HOST) will be used instead. 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 E(VMWARE_PROXY_PORT) will be used instead. required: false type: int description: description: - Description of the Distributed Switch. type: str switch_name: aliases: - switch - dvswitch description: - The name of the distribute vSwitch to create or remove. required: true type: str health_check: default: teaming_failover: false teaming_failover_interval: 0 vlan_mtu: false vlan_mtu_interval: 0 description: - Dictionary which configures Health Check for the Distributed Switch. suboptions: teaming_failover: default: false description: Teaming and failover health check. type: bool teaming_failover_interval: default: 0 description: - Teaming and failover health check interval (minutes). - The default value is 1 in the vSphere Client if the Teaming and failover health check is enabled. type: int vlan_mtu: default: false description: VLAN and MTU health check. type: bool vlan_mtu_interval: default: 0 description: - VLAN and MTU health check interval (minutes). - The default value is 1 in the vSphere Client if the VLAN and MTU health check is enabled. type: int type: dict uplink_prefix: default: 'Uplink ' description: - The prefix used for the naming of the uplinks. - Only valid if the Distributed Switch will be created. Not used if the Distributed Switch is already present. - Uplinks are created as Uplink 1, Uplink 2, etc. pp. by default. type: str network_policy: description: - Dictionary which configures the different default security values for portgroups. - If set, these options are inherited by the portgroups of the DVS. required: false suboptions: forged_transmits: default: false description: Indicates whether forged transmits are allowed. type: bool mac_changes: default: false description: Indicates whether mac changes are allowed. type: bool promiscuous: default: false description: Indicates whether promiscuous mode is allowed. type: bool type: dict switch_version: aliases: - version description: - The version of the Distributed Switch to create. - The version must match the version of the ESXi hosts you want to connect. - The version of the vCenter server is used if not specified. - Required if O(state=present). type: str validate_certs: default: true description: - Allows connection when SSL certificates are not valid. Set to V(false) when certificates are not trusted. - If the value is not specified in the task, the value of environment variable E(VMWARE_VALIDATE_CERTS) will be used instead. type: bool datacenter_name: aliases: - datacenter description: - The name of the datacenter that will contain the Distributed Switch. - Required if O(folder) is not provided. - Mutually exclusive with O(folder) parameter. required: false type: str discovery_proto: aliases: - discovery_protocol choices: - cdp - lldp - disabled default: cdp description: - Link discovery protocol between Cisco and Link Layer discovery. - Required if O(state=present). - 'V(cdp): Use Cisco Discovery Protocol (CDP).' - 'V(lldp): Use Link Layer Discovery Protocol (LLDP).' - 'V(disabled): Do not use a discovery protocol.' type: str uplink_quantity: description: - Quantity of uplink per ESXi host added to the Distributed Switch. - The uplink quantity can be increased or decreased, but a decrease will only be successfull if the uplink isn't used by a portgroup. - Required if O(state=present). type: int discovery_operation: choices: - both - advertise - listen default: listen description: - Select the discovery operation. - Required if O(state=present). type: str multicast_filtering_mode: choices: - basic - snooping default: basic description: - The multicast filtering mode. - 'V(basic) mode: multicast traffic for virtual machines is forwarded according to the destination MAC address of the multicast group.' - 'V(snooping) mode: the Distributed Switch provides IGMP and MLD snooping according to RFC 4541.' type: str
result: description: information about performed operation returned: always sample: changed: false contact: null contact_details: null description: null discovery_operation: both discovery_protocol: cdp dvswitch: test health_check_teaming: false health_check_teaming_interval: 0 health_check_vlan: false health_check_vlan_interval: 0 mtu: 9000 multicast_filtering_mode: basic net_flow_active_flow_timeout: 60 net_flow_collector_ip: 192.168.10.50 net_flow_collector_port: 50034 net_flow_idle_flow_timeout: 15 net_flow_internal_flows_only: false net_flow_observation_domain_id: 0 net_flow_sampling_rate: 4096 result: DVS already configured properly uplink_quantity: 2 uplinks: - Uplink_1 - Uplink_2 version: 6.6.0 type: str