10 DevOps Tools for Network Automation
10 network automation tools: Ansible, Nornir, Netmiko, NAPALM, NetBox, Terraform, Batfish, Containerlab, pyATS and Cisco NSO, with a CI pipeline example.
The ten DevOps tools most used for network automation are Ansible, Nornir, Netmiko, NAPALM, NetBox, Terraform, Batfish, Containerlab, Cisco pyATS and Cisco NSO. Together they cover a source of truth for intent, scripts and playbooks that push changes, validation before and after a change, and virtual labs for testing, all driven from Git and a CI pipeline.
Network teams have moved from typing commands on each device to treating configuration as code, an approach often called NetDevOps. The tools are mostly open source and Python-based, and they work best together rather than alone. This guide explains what each tool does, where it fits in a change pipeline, and shows short examples. For networking basics such as layers and protocols, start with our OSI model guide, the pillar for our networking posts. Tool details were checked against each project's documentation in November 2026.
Key takeaways
- Start with a source of truth (NetBox or Nautobot). Automation that reads device data from spreadsheets stays fragile.
- Ansible is the easiest entry point for network engineers; Nornir suits teams comfortable writing Python.
- Netmiko and NAPALM are libraries that the higher-level tools use to talk to devices over SSH and APIs.
- Batfish checks configurations offline, before anything touches a device. pyATS checks the live network before and after.
- Containerlab gives you a disposable lab of virtual routers and switches so CI can test changes for real.
- Terraform suits API-driven network platforms (cloud VPCs, SDN controllers, firewalls with APIs) more than CLI-only devices.
The NetDevOps workflow these tools support
- Intent lives in a source of truth: devices, interfaces, IP addresses, VLANs, sites.
- Templates in Git (usually Jinja2) turn that data into device configuration.
- A pull request proposes a change. CI renders configs and runs offline validation.
- A lab run deploys the change to virtual devices and runs tests.
- Deployment pushes the change to production in a maintenance window, often in a dry-run first.
- Verification compares network state before and after; a failure triggers rollback.
The 10 tools at a glance
| Tool | Category | Language / interface | Licence model |
|---|---|---|---|
| Ansible | Configuration push and orchestration | YAML playbooks | Open source (Red Hat sells Ansible Automation Platform) |
| Nornir | Automation framework | Python | Open source |
| Netmiko | SSH connection library | Python | Open source |
| NAPALM | Multi-vendor abstraction library | Python | Open source |
| NetBox | Source of truth (IPAM and DCIM) | Web UI, REST and GraphQL APIs | Open source (NetBox Labs sells cloud and enterprise editions) |
| Terraform | Declarative provisioning | HCL | Business Source License (OpenTofu is the open-source fork) |
| Batfish | Offline configuration analysis | Python client (pybatfish) | Open source |
| Containerlab | Virtual network labs | YAML topology, CLI | Open source |
| Cisco pyATS | Network testing and state capture | Python, CLI | Free to use from Cisco |
| Cisco NSO | Model-driven orchestration | YANG, NETCONF, APIs | Commercial |
Source of truth
1. NetBox
NetBox is an open-source application for IP address management (IPAM) and data center infrastructure management (DCIM). It models sites, racks, devices, interfaces, cables, VLANs, prefixes and IP addresses, and exposes everything through REST and GraphQL APIs. Automation reads intended state from NetBox instead of from spreadsheets, and Ansible can use NetBox as a dynamic inventory through the netbox.netbox collection. Nautobot, a fork of NetBox, is an alternative that adds features aimed at automation such as jobs and Git integration.
# inventory/netbox.yml (Ansible dynamic inventory)
plugin: netbox.netbox.nb_inventory
api_endpoint: https://netbox.example.com
validate_certs: true
group_by:
- device_roles
- sites
query_filters:
- status: active
Set the API token with the NETBOX_TOKEN environment variable in CI rather than in the file.
Configuration and orchestration
2. Ansible
Ansible is agentless, which matters for network devices where you cannot install software. For network gear it uses connection plugins from the ansible.netcommon collection: network_cli for SSH CLI sessions, netconf for NETCONF, and httpapi for REST APIs. Vendor collections such as cisco.ios, arista.eos and junipernetworks.junos provide modules for configuration, facts and resource modules that manage interfaces, VLANs or BGP as structured data. Running with --check --diff shows what would change without applying it.
- name: Ensure access VLANs exist
hosts: access_switches
gather_facts: false
connection: ansible.netcommon.network_cli
vars:
ansible_network_os: cisco.ios.ios
tasks:
- name: Configure VLANs
cisco.ios.ios_vlans:
config:
- vlan_id: 110
name: users
- vlan_id: 120
name: voice
state: merged
For more playbook patterns, see 15 Ansible playbooks used in production and real-world Ansible use cases.
3. Nornir
Nornir is a Python automation framework. It handles inventory and runs tasks concurrently across many devices, but you write the logic in plain Python instead of YAML. That makes loops, conditions, error handling and debugging easier for teams that already code. Nornir itself is small; plugins such as nornir_netmiko, nornir_napalm and nornir_scrapli add device connections.
from nornir import InitNornir
from nornir_netmiko.tasks import netmiko_send_command
from nornir_utils.plugins.functions import print_result
nr = InitNornir(config_file="config.yaml")
core = nr.filter(role="core")
result = core.run(task=netmiko_send_command, command_string="show ip bgp summary")
print_result(result)
4. Cisco NSO
Cisco Network Services Orchestrator is a commercial, model-driven orchestration platform. It uses YANG models for services and devices, talks to devices through network element drivers (NETCONF, CLI and others), and applies changes as transactions across many devices, with rollback if any part fails. Service providers and large enterprises use it to automate multi-device services. It suits organisations that need transactional multi-vendor changes and are prepared for a commercial platform and YANG skills.
Device connection libraries
5. Netmiko
Netmiko is a Python library that simplifies SSH connections to network devices. It handles prompts, paging and timing for many platforms through a device_type setting. It is the quickest way to script a one-off task, and it powers higher-level tools.
import os
from netmiko import ConnectHandler
device = {
"device_type": "cisco_ios",
"host": "10.0.0.11",
"username": "netops",
"password": os.environ["NET_PASSWORD"],
}
with ConnectHandler(**device) as conn:
print(conn.send_command("show version"))
6. NAPALM
NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) gives one Python API across vendors. Getters such as get_facts() and get_interfaces() return the same structure from different platforms. For changes it offers a candidate workflow: load_merge_candidate() or load_replace_candidate(), then compare_config() to see the diff, then commit_config() or discard_config(), with rollback() available afterwards on supported drivers. Ansible and Nornir both have NAPALM integrations.
Validation and testing
7. Batfish
Batfish analyses network configurations without touching devices. You give it a snapshot of config files; it builds a model of the network and answers questions such as "can host A reach host B on TCP 443", "which ACL lines are never hit" or "do BGP sessions come up". In CI, render the proposed configs, load them into Batfish, and fail the pull request if a policy check fails.
from pybatfish.client.session import Session
bf = Session(host="localhost")
bf.set_network("campus")
bf.init_snapshot("snapshots/proposed", name="proposed", overwrite=True)
issues = bf.q.initIssues().answer().frame()
undefined = bf.q.undefinedReferences().answer().frame()
assert undefined.empty, undefined
8. Cisco pyATS
pyATS is Cisco's Python test framework, and its Genie library parses show-command output into structured data for many platforms. A common pattern is to capture network state before a change (pyats learn for features such as BGP, OSPF or interfaces), apply the change, capture again, and diff the two (pyats diff). Tests can also assert expected state, such as all BGP neighbours being established.
9. Containerlab
Containerlab builds network labs from a YAML topology file using container-based network operating systems (for example Nokia SR Linux and Arista cEOS) and, through vrnetlab, VM-based images. Because a lab is a file, CI can create it, run Ansible or Nornir against it, test with pyATS or simple pings, and destroy it.
# lab.clab.yml
name: ci-lab
topology:
nodes:
leaf1:
kind: nokia_srlinux
image: ghcr.io/nokia/srlinux
leaf2:
kind: nokia_srlinux
image: ghcr.io/nokia/srlinux
links:
- endpoints: ["leaf1:e1-1", "leaf2:e1-1"]
sudo containerlab deploy -t lab.clab.yml
# run playbooks and tests against the lab nodes
sudo containerlab destroy -t lab.clab.yml
Provisioning API-driven networks
10. Terraform
Terraform manages resources through providers that call APIs, and it keeps state so it can plan changes before applying them. In networking it fits best where the platform exposes an API: cloud networks (AWS VPCs, Azure VNets, Google VPCs), SDN controllers such as Cisco ACI, and firewalls such as Palo Alto Networks through the panos provider. For CLI-only switches, Ansible or Nornir is usually the better fit. HashiCorp moved Terraform to the Business Source License in 2023; OpenTofu is the open-source fork under the Linux Foundation.
resource "aws_vpc" "core" {
cidr_block = "10.20.0.0/16"
enable_dns_hostnames = true
tags = { Name = "core-vpc" }
}
resource "aws_subnet" "app_a" {
vpc_id = aws_vpc.core.id
cidr_block = "10.20.1.0/24"
availability_zone = "ap-south-1a"
}
Our IaC tools ranking compares Terraform with Pulumi, CloudFormation and others.
Putting it together: a CI pipeline for network changes
# .gitlab-ci.yml (sketch)
stages: [render, validate, lab, deploy]
render:
stage: render
script:
- ansible-playbook render_configs.yml # NetBox data + Jinja2 -> configs/
artifacts:
paths: [configs/]
batfish:
stage: validate
script:
- python ci/batfish_checks.py configs/
lab-test:
stage: lab
script:
- sudo containerlab deploy -t lab.clab.yml
- ansible-playbook -i lab_inventory.yml deploy.yml
- python ci/pyats_checks.py
after_script:
- sudo containerlab destroy -t lab.clab.yml
production:
stage: deploy
when: manual
script:
- ansible-playbook -i inventory/netbox.yml deploy.yml --check --diff
- ansible-playbook -i inventory/netbox.yml deploy.yml
The manual production job keeps a human approval in the loop. Pre and post checks with pyATS around the production run show whether the change did what was intended.
Protocols and data models behind the tools
The tools above talk to devices in a handful of ways. Knowing which one a platform supports tells you which tool will work best.
| Interface | What it is | Used by |
|---|---|---|
| SSH CLI | Sending the commands an engineer would type and parsing text output | Netmiko, Ansible network_cli, Nornir plugins |
| NETCONF (RFC 6241) | XML-based protocol for reading and changing configuration, with candidate datastores and commit on supported devices | Ansible netconf, ncclient, Cisco NSO |
| RESTCONF (RFC 8040) | HTTP interface to YANG-modelled data | Ansible httpapi, Python requests |
| gNMI | gRPC-based interface for configuration and streaming telemetry, often with OpenConfig models | Telemetry collectors, gNMI clients |
| Vendor REST APIs | Controller or appliance APIs | Terraform providers, Ansible httpapi |
YANG (RFC 7950) is the data modelling language behind NETCONF, RESTCONF and gNMI. Structured interfaces return data rather than text, so you parse less and validate more. CLI automation is still common because many production devices support nothing else reliably.
Where network automation meets the rest of DevOps
Network changes often block application releases: a new service needs a VLAN, a firewall rule or a load balancer pool. When those changes are code in Git, application teams can open a pull request against the network repository instead of a ticket, and the same review, CI and audit trail apply. The network team still owns approval, but the waiting time drops. This is the infrastructure-as-code model described in our post on why IaC matters for DevOps teams.
Which tools to start with
| Your situation | Start with |
|---|---|
| Network engineer new to automation | Ansible with a vendor collection, plus NetBox for inventory |
| Comfortable with Python | Nornir with Netmiko or NAPALM |
| Want to stop outages from bad ACLs or routing changes | Batfish in CI |
| Need a safe place to test | Containerlab |
| Mostly cloud networking | Terraform or OpenTofu |
| Service provider with multi-vendor transactional services | Cisco NSO |
Common mistakes in network automation
- Automating before cleaning data. If the inventory is wrong, automation spreads the error faster.
- Pushing whole configs to production without a diff or dry run first.
- Storing device passwords in playbooks. Use Ansible Vault, a secrets manager or CI variables.
- Skipping post-change verification, so failures surface only when users complain.
- Writing one giant playbook. Small, tested roles per feature are easier to review and reuse.
Next steps
Ansible and Terraform are the two tools most job descriptions ask for in network automation roles. Our Ansible interview questions are a useful self-test. The Ansible training and Terraform training run in our Kharadi, Pune classroom and live online.
FAQ
What is network automation in DevOps?
It means managing network configuration as code: storing intent and templates in Git, testing changes in CI, and pushing them to devices with tools such as Ansible or Nornir instead of typing commands by hand.
Is Ansible good for network automation?
Yes. Ansible is agentless, connects over SSH, NETCONF or HTTP APIs, and has vendor collections for Cisco, Arista, Juniper and others. It is the most common starting point for network engineers.
What is the difference between Netmiko and NAPALM?
Netmiko handles SSH sessions and sends commands, returning raw text. NAPALM provides a vendor-neutral API with structured getters and a candidate configuration workflow with diff, commit and rollback.
Why use NetBox for automation?
NetBox holds the intended state of the network (devices, interfaces, IPs, VLANs) in one database with APIs. Automation reads from it, so changes start from accurate, reviewed data rather than spreadsheets.
Can Terraform configure switches and routers?
Only where a provider exists for the platform's API. It works well for cloud networks, SDN controllers and API-driven firewalls. For CLI-managed switches, Ansible or Nornir is usually more practical.
How do I test network changes before production?
Run offline analysis with Batfish on rendered configs, then deploy to a Containerlab topology and run checks with pyATS. Use dry-run mode against production before the real push.
Do I need Python for network automation?
Not to start. Ansible playbooks are YAML. Python becomes useful as you grow, for Nornir, custom Batfish or pyATS tests, and working with APIs.
References
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0