Skip to content

Latest commit

 

History

History
181 lines (145 loc) · 4.61 KB

ansible.netcommon.vlan_parser_filter.rst

File metadata and controls

181 lines (145 loc) · 4.61 KB

ansible.netcommon.vlan_parser

The vlan_parser filter plugin.

Version added: 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)

Parameters

Parameter Choices/Defaults Configuration Comments
data
list / required
This option represents a list containing vlans.
first_line_len
integer
Default:
48
The first line of the list can be first_line_len characters long.
other_line_len
integer
Default:
44
The subsequent list lines can be other_line_len characters.

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

Status

Authors

  • 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.