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
- 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.
| Device | Address (VRF MGMT on the switches) | Notes |
|---|---|---|
| leaf1 | Management1 192.168.100.11/24 | already in VRF MGMT |
| leaf2 | Management1 192.168.100.12/24 | already in VRF MGMT |
| ops | eth0 192.168.100.100/24 | Ubuntu 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
- Read structured data on the CLI
- Enable eAPI in the management VRF
- Call eAPI with curl
- Inventory with Python
- Push a change with Python
- 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.
Every link, as text
- leaf1
Management1to OOB (network) - leaf2
Management1to OOB (network) - ops
eth0to OOB (network) - leaf1
Ethernet1to leaf2Ethernet1
| Node | Device | Image in Add Node | Set to |
|---|---|---|---|
| leaf1 | Arista vEOS | veos-4.33.1.1F | 1 vCPU, 2,048 MB |
| leaf2 | Arista vEOS | veos-4.33.1.1F | 1 vCPU, 2,048 MB |
| ops | EVE-NG GUI server (Docker) | eve-gui-server:latest | 1 vCPU, 2,048 MB |
How to open this lab
Sign in to your workspace at
lab.cloudlabbox.com.In File Manager, open Shared, then the folder
Arista EOS guided labs.Open
11 - Automating EOS with eAPI and Python and Ansibleand 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
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.