Learning paths › Automation › Files, formatting and regular expressions
Files, formatting and regular expressions
Files and text in the same series: collected output written one file per command, a config diffed against its golden baseline and published side by side as HTML, then regular expressions compiled once and anchored to a line, run across saved captures and a live SSH response alike — version facts, hostname, licence and users, an interface header with its subcommands, and the default route separated from the statics — closing on the same interface table read first with split and then with one regex, and on address objects that give a prefix its range, mask and membership test. Explanation and checks; five written exercises.
Lessons
- Open, read and write files from a script
- Write collected output to a file
- Drive the device from a command file
- Normalise user input before comparing it
- Break show output into rows and fields
- Colour terminal output with escape sequences
- Number filenames with enumerate
- Save one file per command collected
- Diff a config against its golden baseline
- Publish the diff as side-by-side HTML
- Find a pattern in device output
- Compile one pattern and reuse it
- Anchor a match to a line, not the string
- Extract version facts from a saved capture
- Pull hostname, licence and users from running config
- Match an interface header and its subcommands
- Separate the default route from static routes
- Feed a live SSH response to the same parser
- Handle CRLF line endings from a live session
- Read the interface table with split
- Read the same table with one regex
- Turn an address string into an object
- Work out a prefix's range and mask
- Accept only addresses inside one subnet
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
- 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
- Parsing output and knowing which variable wins
- Jinja filters and PAN-OS automation
- Loops, callbacks, strategy and run control
- Roles, imports and writing your own module
- Running playbooks from AWX