Labs / The Architect / Automation: REST APIs, Ansible & SDN

Lab 2 of 3 ยท Automation: REST APIs, Ansible & SDN

Network automation: Ansible pushes the config

Push router config from code with Ansible, then catch and undo drift.

Open this lab Pro 6 steps

The idea

Network automation writes each router's wanted configuration down once, as files, and lets a tool push it. Here Ansible, on controlNode, gives officeRouter and branchRouter the static routes that let the laptop reach webServer, then catches a change made by hand.

One template, data per router
One template, data per router
Compare, then push the difference
Compare, then push the difference

Steps

  1. The routers know only their own networks

    Start from nothing, so every route you see later is Ansible's work. Ping webServer from the laptop, then print officeRouter's running config: what its routing software, FRR, runs now.

    laptop:~# ping -c 2 -W 1 10.0.2.10
    officeRouter:~# vtysh -c 'show running-config'
  2. The inventory: what Ansible manages

    Ansible needs to know which devices it manages and how to log in to them: that list is the inventory, devices in groups. Read it, then check Ansible can manage the routers group.

    controlNode:~# cat /etc/ansible/hosts.yml
    controlNode:~# ansible routers -m ping

Pro

4 more steps in the app

  1. Intent as data: variables and a template
  2. Push it
  3. Run it again: changed=0
  4. Drift: a change made by hand
Get Pro

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Open this lab