ansible.netcommon.vlan_parser filter – The vlan_parser filter plugin.
Note
This filter plugin is part of the ansible.netcommon collection (version 7.1.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install ansible.netcommon
.
To use it in a playbook, specify: ansible.netcommon.vlan_parser
.
New in ansible.netcommon 1.0.0
Synopsis
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
)
Keyword parameters
This describes keyword parameters of the filter. These are the values key1=value1
, key2=value2
and so on in the following
example: input | ansible.netcommon.vlan_parser(key1=value1, key2=value2, ...)
Parameter |
Comments |
---|---|
This option represents a list containing vlans. |
|
The first line of the list can be first_line_len characters long. Default: |
|
The subsequent list lines can be other_line_len characters. Default: |
Notes
Note
The filter plugin extends vlans when data provided in range or comma separated.
Examples
# 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