New in version 2.4.
| Parameter | Choices/Defaults | Comments |
|---|---|---|
| description | Specify VLAN description, minimum of 1 character, maximum of 80 characters. | |
| name | Name of VLAN, minimum of 1 character, maximum of 31 characters. | |
| state |
| Manage the state of the resource. |
| vlan_id | Single VLAN ID, in the range from 1 to 4094. | |
| vlan_range | Range of VLANs such as 2-10 or 2,5,10-15, etc. |
- 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 }}"
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 the VLAN after executing module or null when using vlan_range Sample: {'name': 'VLAN_APP', 'vlan_id': '20', 'description': 'vlan for app'} |
| end_state_vlans_list list | always | list of VLANs after the module is executed Sample: ['1', '2', '3', '4', '5', '20', '100'] |
| existing dict | always | k/v pairs of existing vlan or null when using vlan_range Sample: {'name': 'VLAN_APP', 'vlan_id': '20', 'description': ''} |
| existing_vlans_list list | always | list of existing VLANs on the switch prior to making changes Sample: ['1', '2', '3', '4', '5', '20'] |
| proposed dict | always | k/v pairs of parameters passed into module (does not include vlan_id or vlan_range) Sample: {'name': 'VLAN_APP', 'vlan_id': '20', 'description': 'vlan for app'} |
| proposed_vlans_list list | always | list of VLANs being proposed Sample: ['100'] |
| updates list | always | command string sent to the device Sample: ['vlan 20', 'name VLAN20'] |
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_vlan_module.html