CLI Is Not the Problem
I want to be clear about something before anything else: the CLI works. OSPF converges. BGP sessions come up. VLANs get configured. The command line has been the backbone of network operations for decades and it's not going anywhere.
The problem isn't CLI. The problem is what happens when you have 500 devices that all need the same change, and you're the one who has to make it.
What Manual Operations Actually Cost You
Think about a typical change: you need to add a new VLAN across 60 access switches in three buildings. If you're fast, that's 15 minutes per switch. That's 15 hours of work, most of it copying and pasting the same four commands. And somewhere in hour 12, you'll mistype a VLAN ID and spend the next two hours finding the one switch that's wrong.
That's not a hypothetical. That's Tuesday for most network teams.
The problems with manual CLI operations compound over time. Config drift happens when someone SSHes into a device at 2am to fix an outage and forgets to document the change. Audit trails don't exist unless someone writes a ticket. Rollbacks mean reversing changes by hand, hoping you remember everything that was touched. And when a senior engineer leaves, the institutional knowledge about why certain configs exist often leaves with them.
Automation doesn't eliminate these problems completely. But it shrinks them from organizational risks to manageable issues.
The Programmability Stack
Network programmability didn't arrive all at once. It evolved through a series of approaches, each fixing problems the previous one left behind.
SSH and CLI Scraping (The Starting Point)
The first generation of network automation was screen scraping. Tools like Expect, Netmiko, and Paramiko SSH into a device, send CLI commands, and parse the text output. It works. It's also fragile.
Parsing text output is brittle because vendors change their output formats between software versions. A show interface output on IOS 15 looks different from IOS-XE 17. Your script breaks on upgrade. You spend more time maintaining parse logic than you save on manual work.
NETCONF and YANG (Structured Data)
NETCONF (RFC 6241) solved the parsing problem by giving you structured data instead of text. It runs over SSH, uses XML for data encoding, and follows a client-server model where you request or modify specific data objects.
YANG models define the data structure. Think of a YANG model as a schema for device configuration and state. The model tells you exactly what fields exist, what types they are, and what's valid. OpenConfig published vendor-neutral YANG models for common constructs like interfaces, BGP, and OSPF. Vendors also publish their own native YANG models for things OpenConfig doesn't cover.
The NETCONF operations you'll use most are get-config (read current config), edit-config (modify config), and commit (apply changes). The commit model means you can build a candidate config, validate it, and apply it atomically, which is a significant improvement over typing CLI commands one at a time.
gNMI (Streaming Telemetry)
gNMI (gRPC Network Management Interface) takes the structured data model of NETCONF and adds streaming. Instead of polling a device every 60 seconds to check interface counters, the device pushes updates to your collector as they happen. You get sub-second visibility into what the network is doing.
gNMI uses the same YANG models as NETCONF for consistency. Subscribe to a path like /interfaces/interface[name=eth0]/state/counters and the device streams that data at whatever interval you specify. This is how modern network observability works in large-scale environments.
REST and RESTCONF
RESTCONF (RFC 8040) exposes YANG-modeled data over HTTP using standard REST operations (GET, POST, PUT, PATCH, DELETE). If you're more comfortable with REST APIs than NETCONF's XML, RESTCONF is a reasonable alternative for configuration tasks. It's not ideal for high-frequency telemetry, where gNMI is the better choice, but for one-off config changes it's straightforward.
Python for Network Automation: Picking the Right Tool
Three tools come up most often when network engineers start writing automation code.
Netmiko (SSH-based, quick to start)
Netmiko is a Python library that wraps Paramiko and handles the vendor-specific quirks of SSH sessions across different platforms. If you need to run CLI commands against a device that doesn't support NETCONF, Netmiko is usually the fastest path. Good for legacy devices. Not ideal if you can use structured data instead.
Nornir (Python-native, concurrent)
Nornir is a Python framework for running tasks against an inventory of devices in parallel. Unlike Ansible, it's pure Python, so you have full control over logic and error handling. It's a good choice for teams that are comfortable with Python and want to build complex workflows without Ansible's abstractions getting in the way.
Ansible (Declarative, good for teams)
Ansible uses YAML playbooks to describe desired state. It has network modules for dozens of vendors. If your team includes people who aren't Python programmers, Ansible is often easier to adopt than Nornir or raw Python scripts. The tradeoff is that complex logic in Ansible gets awkward quickly.
The First Automation Worth Writing
Don't start with the most complex thing. Start with the most boring thing.
My recommendation is always config backup. Write a script that connects to every device in your inventory, runs show running-config, saves the output to a file named after the device and timestamp, and commits it to a Git repo. Schedule it to run nightly.
This gives you an audit trail of every config change. It gives you rollback capability. And it forces you to build and maintain an accurate device inventory, which you'll need for every automation task that comes after. The script itself takes a few hours to write. The value compounds for years.
Idempotency: Why It Matters
Idempotency means running your automation twice produces the same result as running it once. If your script adds a VLAN and you run it again, it shouldn't add the VLAN a second time or error out because it already exists.
This matters because automation runs at scale and sometimes runs more than once due to retries, failures, or human error. If your scripts aren't idempotent, you'll eventually corrupt a device config by applying the same change twice. Build idempotency in from the start. Check whether the desired state already exists before trying to apply it.
Source of Truth: The Foundation Everything Else Builds On
Automation without a source of truth is just faster manual configuration. You'll eventually automate yourself into a state where nobody knows what the network should look like, only what it currently does.
A source of truth is a system that defines intended state: what devices exist, what their hostnames are, what VLANs they carry, what their IP addresses are. Tools like NetBox and Nautobot are purpose-built for this. A well-structured Git repo can work for smaller environments.
The discipline is: before you automate a change, the source of truth defines what the change is. Your automation reads from the source of truth and makes the network match it. Changes go into the source of truth first, then propagate to the network. That's the model that scales.
The Practical Takeaway
Automate the most boring task first, not the most complex one. Get config backup working. Build your device inventory. Make sure your scripts are idempotent. Those three things will save you more time than any sophisticated automation project, and they'll teach you the fundamentals you need to build everything else.
The engineers who get the most out of network automation aren't the ones who went straight to intent-based networking. They're the ones who started with something small, made it reliable, and built from there.
Watch the video
Prefer video? The full network automation series is on YouTube.
Next in this series
What is a REST API and Why Every Network Engineer Should Care →
Comments (0)
Please sign in to comment.