parse_cli_textfsm¶
Collection Note
This module is part of the ansible.netcommon collection. To install the collection, use:
Added in version1.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 - C(data | ansible.netcommon.parse_cli_textfsm(template.yml))
- This plugin is deprecated and will be removed in a future release after 2027-02-01, please Use ansible.utils.cli_parse instead.
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| template str |
The template to compare it with. For example C(data | ansible.netcommon.parse_cli_textfsm(template.yml)), in this case C(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.builtin.debug:
msg: "{{ device_neighbors }}"
# Task Output
# -----------
#
# TASK [Fetch command output]
# ok: [rtr-1]
# 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"
# }
# ]
# }
Authors¶
- Peter Sprygada (@privateip)