Network VLAN filters
Use theansible.netcommon.vlan_parserfilter to transform an unsorted list of VLAN integers into a
sorted string list of integers according to IOS-like VLAN list rules. This list has the following properties:
Vlans are listed in ascending order.Three or more consecutive VLANs are listed with a dash.The first line of the list can be first_line_len characters long.Subsequent list lines can be other_line_len characters.
To sort a VLAN list:
This example renders the following sorted list:
Another example Jinja template:
This allows for the dynamic generation of VLAN lists on a Cisco IOS tagged interface. You can store an exhaustive raw list of the exact VLANs required for an interface and then compare that to the parsed IOS output that would actually be generated for the configuration.