Infrastructure and Automation · Topic 2 of 8
Simulation, Test and Automation Tools
Learn what Cisco Modeling Labs and pyATS do for network simulation and testing, and compare the automation tools Ansible, Terraform and Cisco NSO.
- 5 min
- CML simulates networks with virtual nodes and has an API.
- pyATS is a Python test framework, and Genie parses command output into structured data.
- A pyATS testbed file is YAML and lists the devices and how to connect.
What it is
Simulation and test tools let you build and check a network without risking a live one, and automation tools apply changes to real infrastructure.
Cisco Modeling Labs and pyATS are the simulation and test tools on the outline. Ansible, Terraform and Cisco NSO are the automation tools.
Used together, they let you design a change, test it in a lab, and then apply it to production the same way every time.
How it works
Each tool has a clear job, so match the tool to the stage of the work.
Cisco Modeling Labs
Cisco Modeling Labs, or CML, is a network simulation platform. You draw a topology of virtual routers, switches and other nodes, and run them as virtual machines that run real network operating system images.
The benefits are:
- A safe lab for learning and for testing a change before production.
- A topology that can be saved, shared and rebuilt on demand.
- A REST API and a Python client, so labs can be created and started by a script or by a CI pipeline.
- The ability to load a copy of a design to test a configuration against it.
CML suits proof of concept work and training. It does not replace a test in the real environment, because virtual nodes may behave differently from hardware.
pyATS and Genie
pyATS is a Python based test framework from Cisco. Genie is the library of parsers and models that sits on it.
It works from a testbed file, which is a YAML description of your devices, their addresses and how to log in.
devices:
R1:
os: iosxe
type: router
connections:
cli:
protocol: ssh
ip: 192.0.2.1
Genie parsers turn the text output of a command into a Python dictionary, so a test can check structured data.
from genie.testbed import load
testbed = load("testbed.yaml")
device = testbed.devices["R1"]
device.connect()
output = device.parse("show ip interface brief")
print(output["interface"]["GigabitEthernet1"]["ip_address"])
The common use is to take a snapshot of the network before a change, make the change, take a second snapshot and compare the two. This shows exactly what the change affected. pyATS can also run as part of a CI pipeline.
Ansible
Ansible is an agentless automation tool. It connects over SSH or an API, so nothing has to be installed on the devices. You describe tasks in YAML playbooks, and the next pages show how to read them.
It is easy to learn and has many modules for servers and network devices.
Terraform
Terraform describes infrastructure in a declarative language and builds it through providers. You write what you want, run terraform plan to preview, and terraform apply to create or change it.
Terraform keeps a state file that records what it manages. It is strong for creating cloud and platform resources, and providers exist for Cisco platforms such as ACI and Meraki.
Cisco NSO
Network Services Orchestrator is a model driven orchestrator. It uses YANG models for devices and for services, and network element drivers to talk to many vendors.
Changes are transactional and can be rolled back. It suits service provisioning in large, multi vendor networks.
Comparing the automation tools
| Point | Ansible | Terraform | Cisco NSO |
|---|---|---|---|
| Language | YAML playbooks | HCL configuration | YANG models, service templates |
| Style | Mostly procedural task lists | Declarative | Declarative, model driven |
| Agent on device | No | No | No |
| State | No central state by default | State file | Database of device and service data |
| Strength | Configuration and tasks | Provisioning resources | Multi vendor service orchestration |
| Rollback | Not built in | Re-apply an earlier version of the code | Transactional rollback |
Where each tool fits
- Learn or test a design: CML.
- Check that a change did what it should: pyATS.
- Run configuration tasks across servers and devices: Ansible.
- Create and track cloud or platform resources: Terraform.
- Orchestrate services across many vendors: NSO.
Think of CML as the place to build a lab, pyATS as the way to test it, and Ansible, Terraform or NSO as the ways to change the real network.
What to remember for the exam
Seven facts cover this topic.
- CML simulates networks with virtual nodes and has an API.
- pyATS is a Python test framework, and Genie parses command output into structured data.
- A pyATS testbed file is YAML and lists the devices and how to connect.
- Ansible is agentless and uses YAML playbooks.
- Terraform is declarative, uses
planandapply, and keeps a state file. - NSO is model driven with YANG and supports multi vendor, transactional changes.
- Test in a lab before production, and compare before and after snapshots.
Common mistakes
Four mistakes are typical.
Treating a simulation as identical to hardware. Virtual nodes can behave differently, so confirm in production.
Thinking pyATS only configures. Its main job is testing and verification.
Calling Ansible declarative in all cases. Playbooks are mostly ordered task lists, though many modules are idempotent.
Forgetting Terraform state. Losing the state file makes it forget what it created.
Keep testbed files and playbooks free of plain text passwords, because they are often stored in Git.
Check yourself
Work through these three questions.
What is Cisco Modeling Labs used for?
It simulates networks with virtual nodes, so you can learn, build labs and test changes safely.
What does a pyATS testbed file contain?
It is a YAML description of the devices, their addresses and how to connect to them.
Which tool keeps a state file and uses
planandapply?Terraform.
Topic 2 of 8 in Infrastructure and Automation
Test yourself on Infrastructure and Automation
The full Cisco CCNA 200-901 DEVASC question bank has 808 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.