New in version 2.4.
Parameter | Choices/Defaults | Comments |
---|---|---|
access_vlan | If mode=access , used as the access VLAN ID, in the range from 1 to 4094. | |
interface required | Full name of the interface, i.e. 40GE1/0/22. | |
mode |
| The link type of an interface. |
native_vlan | If mode=trunk , used as the trunk native VLAN ID, in the range from 1 to 4094. | |
state |
| Manage the state of the resource. |
trunk_vlans | If mode=trunk , used as the VLAN range to ADD or REMOVE from the trunk, such as 2-10 or 2,5,10-15, etc. |
Note
state=absent
, VLANs can be added/removed from trunk links and the existing access VLAN can be ‘unconfigured’ to just having VLAN 1 on that interface.port trunk allow-pass vlan
command. Use verbose mode to see commands sent.state=unconfigured
, the interface will result with having a default Layer 2 interface, i.e. vlan 1 in access mode.- name: switchport module test hosts: cloudengine connection: local gather_facts: no vars: cli: host: "{{ inventory_hostname }}" port: "{{ ansible_ssh_port }}" username: "{{ username }}" password: "{{ password }}" transport: cli tasks: - name: Ensure 10GE1/0/22 is in its default switchport state ce_switchport: interface: 10GE1/0/22 state: unconfigured provider: '{{ cli }}' - name: Ensure 10GE1/0/22 is configured for access vlan 20 ce_switchport: interface: 10GE1/0/22 mode: access access_vlan: 20 provider: '{{ cli }}' - name: Ensure 10GE1/0/22 only has vlans 5-10 as trunk vlans ce_switchport: interface: 10GE1/0/22 mode: trunk native_vlan: 10 trunk_vlans: 5-10 provider: '{{ cli }}' - name: Ensure 10GE1/0/22 is a trunk port and ensure 2-50 are being tagged (doesn't mean others aren't also being tagged) ce_switchport: interface: 10GE1/0/22 mode: trunk native_vlan: 10 trunk_vlans: 2-50 provider: '{{ cli }}' - name: Ensure these VLANs are not being tagged on the trunk ce_switchport: interface: 10GE1/0/22 mode: trunk trunk_vlans: 51-4000 state: absent provider: '{{ cli }}'
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
changed boolean | always | check to see if a change was made on the device Sample: True |
end_state dict | always | k/v pairs of switchport after module execution Sample: {'interface': '10GE1/0/22', 'access_vlan': '20', 'mode': 'access', 'switchport': 'enable'} |
existing dict | always | k/v pairs of existing switchport Sample: {'interface': '10GE1/0/22', 'access_vlan': '10', 'mode': 'access', 'switchport': 'enable'} |
proposed dict | always | k/v pairs of parameters passed into module Sample: {'interface': '10GE1/0/22', 'access_vlan': '20', 'mode': 'access'} |
updates list | always | command string sent to the device Sample: ['10GE1/0/22', 'port default vlan 20'] |
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
This module is flagged as community which means that it is maintained by the Ansible Community. See Module Maintenance & Support for more info.
For a list of other modules that are also maintained by the Ansible Community, see here.
Hint
If you notice any issues in this documentation you can edit this document to improve it.
© 2012–2018 Michael DeHaan
© 2018 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.7/modules/ce_switchport_module.html