Your browser failed to load CSS style sheets. Your browser or web proxy might not support elliptic-curve TLS

Building network automation solutions

6 week online course

Start now!
back to overview

Parsing Printouts with Ansible Regular Expression Filters

Ansible is great at capturing and using JSON-formatted data returned by REST API (or any other script or method it can invoke), but unfortunately some of us still have to deal with network devices that cannot even spell structured data or REST.

There are plenty of great open-source tools that help you parse text printouts, including TextFSM, ntc-ansible and NAPALM get functions, but sometimes you have to parse a printout that nobody bothered with before.

Ideally, you’d write a short Ansible plug-in (or Jinja2 filter) in Python to do the parsing, or you could go for a QDS (Quick-and-Dirty Solution) and extract the information directly in Ansible playbook with a Jinja2 regex filter.

No comments:

You don't have to log in to post a comment, but please do provide your real name/URL. Anonymous comments might get deleted.

Sidebar