Network automation lab 19 of 27

Troubleshooting lab: Netmiko, Jinja2 and Ansible automation that worked yesterday

A colleague's automation project fails in eight different ways across two routers and the workstation: wrong device types, a mistyped address, SSH disabled, a user without privilege, an undefined template variable, broken YAML, the wrong Ansible connection and a task that is never idempotent. Find each fault from its symptoms, fix it, and prove the whole project runs clean twice.

Run this lab

It needs Lite: its 3 nodes are set to 3 vCPU and 2,048 MB in total. That fits the free demo too.

In your workspace: Shared, then Network Automation - CCNA and CCNP Automation guided labs, then 19 - Troubleshooting lab - Netmiko Jinja2 and Ansible automation that worked yesterday

Try it free for 30 minutesRun it on Lite from £3 a day

The free demo needs no card and no email. Every lab plan includes every guided lab.

Level
Advanced
Time
About 75 minutes
Nodes need
3 vCPU, 2,048 MB
Smallest plan
Lite

The scenario

Your colleague Tom built a small automation project for the Leeds routers before going on holiday: collect.py backs up the configurations with Netmiko, render.py renders each router's Loopback0 configuration from a Jinja2 template, and an Ansible playbook pushes NTP and the rendered loopbacks. "It all worked yesterday." Today nothing does. Some faults are in the project and some on the routers. Find and fix every fault, one at a time, and finish with a project that runs clean twice in a row.

RouterMgmt addressIntended state
r110.10.20.11SSH for user netops (privilege 15), NTP 10.10.20.10, Loopback0 10.255.0.1/32 "Router ID r1"
r210.10.20.12the same, with Loopback0 10.255.0.2/32 "Router ID r2"

Project in ~/lab/project: inventory.yaml, collect.py, vars.yaml, templates/loopback.j2, render.py, and ansible/ (ansible.cfg, hosts.yml, group_vars/routers.yml, baseline.yml). Login netops / NetOps-Lab1; both routers' consoles are open to you.

What you’ll practise

  • Read Python tracebacks, Netmiko exceptions, Jinja2 errors and Ansible failures to locate a fault
  • Separate network, transport, authentication, authorisation and code problems methodically
  • Recognise silent failures (wrong data, no exception) and validate outputs
  • Fix inventory, connection and YAML errors in an Ansible project
  • Diagnose and fix a non-idempotent configuration task

The tasks

  1. Reproduce and triage
  2. Get r2 backed up (three faults on one line, and one on the router)
  3. A backup that "worked" but is wrong
  4. The template
  5. The playbook won't even load
  6. The wrong kind of connection
  7. A task that's never finished
  8. Prove it and write it up

The Lab Tasks pane has the scenario, these tasks, the checks to run, hints and the full solution.

Topology and devices

The network as it opens in EVE-NG, drawn from the lab’s own canvas, and the image each node runs.

Topology of Troubleshooting lab - Netmiko Jinja2 and Ansible automation that worked yesterday3 nodes and 1 network, 3 links. Every link is listed as text below the diagram.devboxr1r2Mgmteth0Gi0/0Gi0/0
3 nodes and 1 network, with the interface names each link uses. On a narrow screen, scroll the diagram sideways.
Nodes in Troubleshooting lab: Netmiko, Jinja2 and Ansible automation that worked yesterday, with the image each runs and the vCPU and RAM it’s set to
NodeDeviceImage in Add NodeSet to
devboxEVE-NG GUI server (Docker)eve-gui-server:latest1 vCPU, 1,024 MB
r1Cisco IOSvvios-adventerprisek9-m.spa.159-3.m91 vCPU, 512 MB
r2Cisco IOSvvios-adventerprisek9-m.spa.159-3.m91 vCPU, 512 MB

How to open this lab

  1. Sign in to your workspace at lab.cloudlabbox.com.

  2. In File Manager, open Shared, then the folder Network Automation - CCNA and CCNP Automation guided labs.

  3. Open 19 - Troubleshooting lab - Netmiko Jinja2 and Ansible automation that worked yesterday and start its nodes, then open Lab Tasks for the scenario and the steps.

The lab is read-only. You can start the nodes and configure the devices, but changes to the topology can’t be saved. To change it, rebuild it in your own folder.

More Network automation labs

All Network automation labs

Related labs in other courses

CloudLabBox is independent of Cisco. The lab follows exam topics and isn’t vendor training material; vendor names identify the exams and the images in the workspace.