community.general.ce_vlan (0.1.1) — module

Manages VLAN resources and attributes on Huawei CloudEngine switches.

Authors: QijunPan (@QijunPan)

preview | supported by community

Install collection

Install with ansible-galaxy collection install community.general:==0.1.1


Add to requirements.yml

  collections:
    - name: community.general
      version: 0.1.1

Description

Manages VLAN configurations on Huawei CloudEngine switches.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: vlan 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 a range of VLANs are not present on the switch
    ce_vlan:
      vlan_range: "2-10,20,50,55-60,100-150"
      state: absent
      provider: "{{ cli }}"

  - name: Ensure VLAN 50 exists with the name WEB
    ce_vlan:
      vlan_id: 50
      name: WEB
      state: absent
      provider: "{{ cli }}"

  - name: Ensure VLAN is NOT on the device
    ce_vlan:
      vlan_id: 50
      state: absent
      provider: "{{ cli }}"

Inputs

    
name:
    description:
    - Name of VLAN, minimum of 1 character, maximum of 31 characters.

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Manage the state of the resource.

vlan_id:
    description:
    - Single VLAN ID, in the range from 1 to 4094.

vlan_range:
    description:
    - Range of VLANs such as C(2-10) or C(2,5,10-15), etc.

description:
    description:
    - Specify VLAN description, minimum of 1 character, maximum of 80 characters.

Outputs

changed:
  description: check to see if a change was made on the device
  returned: always
  sample: true
  type: bool
end_state:
  description: k/v pairs of the VLAN after executing module or null when using vlan_range
  returned: always
  sample:
    description: vlan for app
    name: VLAN_APP
    vlan_id: '20'
  type: dict
end_state_vlans_list:
  description: list of VLANs after the module is executed
  returned: always
  sample:
  - '1'
  - '2'
  - '3'
  - '4'
  - '5'
  - '20'
  - '100'
  type: list
existing:
  description: k/v pairs of existing vlan or null when using vlan_range
  returned: always
  sample:
    description: ''
    name: VLAN_APP
    vlan_id: '20'
  type: dict
existing_vlans_list:
  description: list of existing VLANs on the switch prior to making changes
  returned: always
  sample:
  - '1'
  - '2'
  - '3'
  - '4'
  - '5'
  - '20'
  type: list
proposed:
  description: k/v pairs of parameters passed into module (does not include vlan_id
    or vlan_range)
  returned: always
  sample:
    description: vlan for app
    name: VLAN_APP
    vlan_id: '20'
  type: dict
proposed_vlans_list:
  description: list of VLANs being proposed
  returned: always
  sample:
  - '100'
  type: list
updates:
  description: command string sent to the device
  returned: always
  sample:
  - vlan 20
  - name VLAN20
  type: list