Learning paths › Automation › Parsing output and knowing which variable wins
Parsing output and knowing which variable wins
Two things a playbook stops working without. First, human-readable output turned into named fields — with Genie, a community template library, or a TextFSM template of your own. Second, knowing which definition of a variable wins: gathered facts, Ansible's own runtime variables, another host's variables, a play's declared inputs, a file loaded mid-run and a registered task result, with when each is evaluated made explicit — closing on the filters that reshape the result, including a fallback for an undefined value, a mapping overlaid on a base, an attribute projected out of every record, JMESPath and the IP address filters. Explanation and checks; two written exercises.
Lessons
- Turn human-readable output into named fields
- Parse show output with pyATS and Genie
- Parse output with the NTC Templates library
- Write a TextFSM template of your own
- Read the facts Ansible gathers per platform
- Use Ansible's own runtime variables
- Read another host's variables at runtime
- Declare a play's inputs separately from its tasks
- Load a variables file while the play runs
- Create a variable from a task result
- Know when each variable is evaluated
- Work out which definition of a variable wins
- Transform a value through a filter pipe
- Supply a fallback for an undefined value
- Choose one of two values from a condition
- Loop over a mapping as a list of records
- Serialize data out to JSON or YAML text
- Parse a file's text back into data
- Pair destinations with their gateways
- Overlay an override mapping on a base
- Project one attribute out of every record
- Flatten nested lists one level at a time
- Query structured data with JMESPath
- Validate and calculate IP address properties
More in Automation
- First scripts that configure devices
- NAPALM: structured data across vendors
- Concurrency, and the Python types device output returns
- Parsing show output and testing conditions
- Readable code, branching and loops
- Build the workstation and the toolchain
- Files, CSV, JSON and pickle
- Paramiko: SSH to devices from Python
- Netmiko at fleet scale
- Tuples, sets and dictionaries for device records
- Exceptions and your first classes
- Plan and build the automation lab
- Files, formatting and regular expressions
- Addresses, functions, modules and classes
- CSV inventories, logging and scheduling
- Netmiko, SCP and structured parsing
- Agents, async and model-driven workflows
- NETCONF, YANG and RESTCONF
- NX-API, pyATS and Genie
- A small GenAI app, end to end
- macOS, Linux and the virtual lab
- Agile delivery and Python fundamentals
- REST APIs, authentication and requests
- Flask, Docker and Jenkins
- Managing a router with NETCONF and RESTCONF
- Ansible: inventory, ad-hoc commands and first playbooks
- Roles and zero-touch provisioning for Linux switches
- Installing the controller and applying a project
- Setting up Python 3
- The Ansible lab and the controller
- Vault, variables and config changes
- Jinja filters and PAN-OS automation
- Loops, callbacks, strategy and run control
- Roles, imports and writing your own module
- Running playbooks from AWX