ce_switchport – Manages Layer 2 switchport interfaces on HUAWEI CloudEngine switches¶
New in version 2.4.
Parameters¶
Notes¶
Note
- When 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.
- When working with trunks VLANs the keywords add/remove are always sent in the port trunk allow-pass vlancommand. Use verbose mode to see commands sent.
- When state=unconfigured, the interface will result with having a default Layer 2 interface, i.e. vlan 1 in access mode.
- This module requires the netconf system service be enabled on the remote device being managed.
- Recommended connection is netconf.
- This module also works with localconnections for legacy playbooks.
Examples¶
- 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
      default_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
      pvid_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
      pvid_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 }}'
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Status¶
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors¶
- QijunPan (@QijunPan)
Hint
If you notice any issues in this documentation, you can edit this document to improve it.
