Arista EOS lab 11 of 20

Automating EOS with eAPI and Python and Ansible

Turn on Arista's eAPI in the management VRF, read structured JSON from the CLI and over HTTPS with curl, collect an inventory and push a VLAN with Python, then make the same kind of change idempotently with an Ansible playbook.

Run this lab

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

In your workspace: Shared, then Arista EOS guided labs, then 11 - Automating EOS with eAPI and Python and Ansible

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
Intermediate
Time
About 70 minutes
Nodes need
3 vCPU, 6,144 MB
Smallest plan
Lite

The scenario

Northwind's operations team wants to stop typing VLANs into switches one by one. Your job is to open a safe automation channel to the leaves (eAPI, only on the out-of-band network, with its own account), prove you can read structured data and make changes from the ops workstation with Python, and then hand the team an Ansible playbook that can run every night without breaking anything.

DeviceAddress (VRF MGMT on the switches)Notes
leaf1Management1 192.168.100.11/24already in VRF MGMT
leaf2Management1 192.168.100.12/24already in VRF MGMT
opseth0 192.168.100.100/24Ubuntu desktop; open it from the canvas; files in /root/lab

Automation account on both switches: user automation, role network-admin, secret Auto-Lab1 (a teaching value).

What you’ll practise

  • Enable eAPI (management api http-commands) in a management VRF with a dedicated automation user
  • Explain JSON-RPC runCmds requests and read structured replies
  • Query EOS with | json on the CLI and with curl from a workstation
  • Use Python requests to collect data from several switches and to push and save configuration
  • Run an Ansible playbook with arista.eos modules over eAPI (httpapi) and explain idempotency

The tasks

  1. Read structured data on the CLI
  2. Enable eAPI in the management VRF
  3. Call eAPI with curl
  4. Inventory with Python
  5. Push a change with Python
  6. Idempotent change with Ansible

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 Automating EOS with eAPI and Python and Ansible3 nodes and 1 network, 4 links. Every link is listed as text below the diagram.leaf1leaf2opsOOBManagement1Management1Ethernet1Ethernet1eth0
3 nodes and 1 network, with the interface names each link uses.
Nodes in Automating EOS with eAPI and Python and Ansible, with the image each runs and the vCPU and RAM it’s set to
NodeDeviceImage in Add NodeSet to
leaf1Arista vEOSveos-4.33.1.1F1 vCPU, 2,048 MB
leaf2Arista vEOSveos-4.33.1.1F1 vCPU, 2,048 MB
opsEVE-NG GUI server (Docker)eve-gui-server:latest1 vCPU, 2,048 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 Arista EOS guided labs.

  3. Open 11 - Automating EOS with eAPI and Python and Ansible 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 Arista EOS labs

All Arista EOS labs

Related labs in other courses

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