The vlan_parser filter plugin.
Version added: 1.0.0
- The filter plugin converts a list of vlans to IOS like vlan configuration.
- Converts list to a list of range of numbers into multiple lists.
vlans_data | ansible.netcommon.vlan_parser(first_line_len = 20, other_line_len=20
)
Note
- The filter plugin extends vlans when data provided in range or comma separated.
# Using vlan_parser
- name: Setting host facts for vlan_parser filter plugin
ansible.builtin.set_fact:
vlans:
[
100,
1688,
3002,
3003,
3004,
3005,
3102,
3103,
3104,
3105,
3802,
3900,
3998,
3999,
]
- name: Invoke vlan_parser filter plugin
ansible.builtin.set_fact:
vlans_ranges: "{{ vlans | ansible.netcommon.vlan_parser(first_line_len = 20, other_line_len=20) }}"
# Task Output
# -----------
#
# TASK [Setting host facts for vlan_parser filter plugin]
# ok: [host] => changed=false
# ansible_facts:
# vlans:
# - 100
# - 1688
# - 3002
# - 3003
# - 3004
# - 3005
# - 3102
# - 3103
# - 3104
# - 3105
# - 3802
# - 3900
# - 3998
# - 3999
# TASK [Invoke vlan_parser filter plugin]
# ok: [host] => changed=false
# ansible_facts:
# msg:
# - 100,1688,3002-3005
# - 3102-3105,3802,3900
# - 3998,3999
- Steve Dodd (@idahood)
Hint
Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.