Skip to content

Latest commit

 

History

History
148 lines (111 loc) · 3.86 KB

ansible.netcommon.parse_cli_textfsm_filter.rst

File metadata and controls

148 lines (111 loc) · 3.86 KB

ansible.netcommon.parse_cli_textfsm

parse_cli_textfsm filter plugin.

Version added: 1.0.0

Synopsis

  • The network filters also support parsing the output of a CLI command using the TextFSM library. To parse the CLI output with TextFSM use this filter.
  • Using the parameters below - data | ansible.netcommon.parse_cli_textfsm(template.yml)

Parameters

Parameter Choices/Defaults Configuration Comments
template
string
The template to compare it with.
For example data | ansible.netcommon.parse_cli_textfsm(template.yml), in this case data represents this option.
value
raw / required
This source data on which parse_cli_textfsm invokes.

Notes

Note

- Use of the TextFSM filter requires the TextFSM library to be installed.

Examples

# Using parse_cli_textfsm

- name: "Fetch command output"
  cisco.ios.ios_command:
    commands:
      - show lldp neighbors
  register: lldp_output

- name: "Invoke parse_cli_textfsm"
  ansible.builtin.set_fact:
    device_neighbors: "{{ lldp_output.stdout[0] | parse_cli_textfsm('~/ntc-templates/templates/cisco_ios_show_lldp_neighbors.textfsm') }}"

- name: "Debug"
  ansible.builtindebug:
    msg: "{{ device_neighbors }}"

# Task Output
# -----------
#
# TASK [Fetch command output]
# ok: [rtr-2]

# TASK [Invoke parse_cli_textfsm]
# ok: [rtr-1]

# TASK [Debug]
# ok: [rtr-1] => {
#     "msg": [
#         {
#             "CAPABILITIES": "R",
#             "LOCAL_INTERFACE": "Gi0/0",
#             "NEIGHBOR": "rtr-3",
#             "NEIGHBOR_INTERFACE": "Gi0/0"
#         },
#         {
#             "CAPABILITIES": "R",
#             "LOCAL_INTERFACE": "Gi0/1",
#             "NEIGHBOR": "rtr-1",
#             "NEIGHBOR_INTERFACE": "Gi0/1"
#         }
#     ]
# }

Status

Authors

  • Peter Sprygada (@privateip)

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.