Skip to content

vlan_expander

Collection Note

This module is part of the ansible.netcommon collection. To install the collection, use:

ansible-galaxy collection install ansible.netcommon
Added in version 2.3.0.

Synopsis

  • Expand shorthand list of VLANs to list all VLANs. Inverse of vlan_parser
  • Using the parameters below - C(vlans_data | ansible.netcommon.vlan_expander)

Parameters

Parameter Defaults / Choices Comments
data
str
required
This option represents a string containing the range of vlans.

Notes

Note

  • The filter plugin extends vlans when data provided in range or comma separated.

Examples

# Using vlan_expander

- name: Setting host facts for vlan_expander filter plugin
  ansible.builtin.set_fact:
    vlan_ranges: "1,10-12,15,20-22"

- name: Invoke vlan_expander filter plugin
  ansible.builtin.set_fact:
    extended_vlans: "{{ vlan_ranges | ansible.netcommon.vlan_expander }}"


# Task Output
# -----------
#
# TASK [Setting host facts for vlan_expander filter plugin]
# ok: [host] => changed=false
#   ansible_facts:
#     vlan_ranges: 1,10-12,15,20-22

# TASK [Invoke vlan_expander filter plugin]
# ok: [host] => changed=false
#   ansible_facts:
#     extended_vlans:
#     - 1
#     - 10
#     - 11
#     - 12
#     - 15
#     - 20
#     - 21
#     - 22

Authors

  • Akira Yokochi (@akira6592)