Network automation lab 7 of 27
Parse CLI output with TextFSM, ntc-templates and TTP
Turn show-command text into structured data: ntc-templates for interfaces, OSPF and CDP, a TextFSM template you write yourself, and a TTP template for the running configuration, then use the results to validate the design and enforce an SSH policy.
Run this lab
It needs Lite: its 4 nodes are set to 4 vCPU and 2,560 MB in total. That fits the free demo too.
In your workspace: Shared, then Network Automation - CCNA and CCNP Automation guided labs, then 07 - Parse CLI output with TextFSM ntc-templates and TTP
- Level
- Intermediate
- Time
- About 85 minutes
- Nodes need
- 4 vCPU, 2,560 MB
- Smallest plan
- Lite
The scenario
Kestrel Freight's design document says the branch triangle has four links, every OSPF adjacency should be FULL, and SSH must follow the security policy (version 2, a 60-second login timeout, at most 2 retries). Nobody knows if that's true. You'll collect the routers' output once, turn it into structured data with three kinds of parser, and produce evidence: which links exist, whether OSPF is healthy, which routers break the SSH policy (then fix them), and which interfaces are missing descriptions.
| Router | Mgmt (Gi0/0) | Gi0/1 | Gi0/2 | Loopback0 |
|---|---|---|---|---|
| r1 | 10.10.20.11 | 10.1.12.1/30 → r2 | 10.1.13.1/30 → r3 | 10.255.0.1 |
| r2 | 10.10.20.12 | 10.1.12.2/30 → r1 | 10.1.23.1/30 → r3 | 10.255.0.2 |
| r3 | 10.10.20.13 | 10.1.13.2/30 → r1 | 10.1.23.2/30 → r2 | 10.255.0.3 |
All three run OSPF area 0 on their links and loopbacks. Files in ~/lab: collect.py (ready to use), design.yaml (the documented links and the SSH policy), parsers.py (helpers with TODOs) and an empty templates/ folder. Login netops / NetOps-Lab1.
What you’ll practise
- Explain why screen-scraping needs a parser and when regular expressions stop being enough
- Parse IOS show commands into lists of dictionaries with ntc-templates
- Validate a documented topology against live CDP neighbours and check every OSPF adjacency
- Write and debug your own TextFSM template, then use it to audit and remediate SSH settings
- Parse configuration text with a TTP template
The tasks
- Collect once, parse many times
- Why a parser? Regex versus TextFSM
- Check every OSPF adjacency
- Validate the design with CDP
- Read the output you need to parse yourself
- Write a TextFSM template, audit and fix SSH
- Parse configuration with TTP
The Lab Tasks pane has the scenario, these tasks, the checks to run, hints and the full solution.
Topology and devices
The network as it opens in EVE-NG, drawn from the lab’s own canvas, and the image each node runs.
Every link, as text
- devbox
eth0to Mgmt (network) - r1
Gi0/0to Mgmt (network) - r2
Gi0/0to Mgmt (network) - r3
Gi0/0to Mgmt (network) - r1
Gi0/1to r2Gi0/1 - r1
Gi0/2to r3Gi0/1 - r2
Gi0/2to r3Gi0/2
| Node | Device | Image in Add Node | Set to |
|---|---|---|---|
| devbox | EVE-NG GUI server (Docker) | eve-gui-server:latest | 1 vCPU, 1,024 MB |
| r1 | Cisco IOSv | vios-adventerprisek9-m.spa.159-3.m9 | 1 vCPU, 512 MB |
| r2 | Cisco IOSv | vios-adventerprisek9-m.spa.159-3.m9 | 1 vCPU, 512 MB |
| r3 | Cisco IOSv | vios-adventerprisek9-m.spa.159-3.m9 | 1 vCPU, 512 MB |
How to open this lab
Sign in to your workspace at
lab.cloudlabbox.com.In File Manager, open Shared, then the folder
Network Automation - CCNA and CCNP Automation guided labs.Open
07 - Parse CLI output with TextFSM ntc-templates and TTPand start its nodes, then open Lab Tasks for the scenario and the steps.
The lab is read-only. You can start the nodes and configure the devices, but changes to the topology can’t be saved. To change it, rebuild it in your own folder.
More Network automation labs
Related labs in other courses
CloudLabBox is independent of Cisco. The lab follows exam topics and isn’t vendor training material; vendor names identify the exams and the images in the workspace.