ansible.netcommon.vlan_parser (6.1.0) — filter

The vlan_parser filter plugin.

| "added in version" 1.0.0 of ansible.netcommon"

Authors: Steve Dodd (@idahood)

Install collection

Install with ansible-galaxy collection install ansible.netcommon:==6.1.0


Add to requirements.yml

  collections:
    - name: ansible.netcommon
      version: 6.1.0

Description

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.

C(vlans_data | ansible.netcommon.vlan_parser(first_line_len = 20, other_line_len=20))

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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,
      ]
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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) }}"

Inputs

    
data:
    description:
    - This option represents a list containing vlans.
    required: true
    type: list

first_line_len:
    default: 48
    description:
    - The first line of the list can be first_line_len characters long.
    type: int

other_line_len:
    default: 44
    description:
    - The subsequent list lines can be other_line_len characters.
    type: int