Network automation lab 10 of 27
RESTCONF configuration management: desired state, native models and idempotency
Manage an IOS XE router's interfaces, OSPF and static routes as a list of RESTCONF resources in YAML: discover the JSON with the 'configure once, read back' technique, choose PUT or PATCH, and build an apply script that only changes what differs, then prove it by forming an OSPF adjacency with a neighbour.
Run this lab
It needs Lite: its 3 nodes are set to 3 vCPU and 5,632 MB in total. That fits the free demo too.
In your workspace: Shared, then Network Automation - CCNA and CCNP Automation guided labs, then 10 - RESTCONF configuration management - desired state native models and idempotency
- Level
- Intermediate
- Time
- About 80 minutes
- Nodes need
- 3 vCPU, 5,632 MB
- Smallest plan
- Lite
The scenario
Kestrel Freight wants the Manchester router xe1 managed only through its API. Its desired state will live in Git as a YAML file of RESTCONF resources, and a script will make the router match it, as often as anyone likes, changing nothing when nothing needs changing. Today's state: the link to the branch router r1, a loopback, OSPF with r1, and a static route to a depot LAN behind r1. r1 is already configured and waiting for xe1 to join OSPF.
| Device | Interface | Address |
|---|---|---|
| xe1 | Gi1 (management) | 10.10.20.21/24 |
| xe1 | Gi2 | to configure: 10.1.13.2/30, "Link to r1 Gi0/1" |
| xe1 | Loopback0 | to configure: 10.255.0.3/32, "Router ID" |
| r1 | Gi0/1 · Loopback0 | 10.1.13.1/30 · 10.255.0.1/32, OSPF area 0 ready |
xe1 also needs OSPF process 1 (router ID 10.255.0.3, area 0 on 10.1.13.0/30 and its loopback) and a static route to 192.0.2.0/24 via r1 (10.1.13.1). Files in ~/lab: rc.py (a small RESTCONF client), show.py (prints any resource as JSON), desired.yaml (one entry so far) and apply.py (with one TODO). Login netops / NetOps-Lab1.
What you’ll practise
- Discover the JSON shape of IETF and Cisco native YANG data by reading it back from the device
- Configure interfaces, OSPF and static routes over RESTCONF with PUT and PATCH
- Represent device configuration as YAML/JSON desired state derived from YANG models
- Make a RESTCONF automation idempotent: read, compare, change only what differs
- Verify the network effect (OSPF adjacency, routes) and save the configuration
The tasks
- Read the client and discover the data
- Apply the first desired-state entry
- Loopback0 with the native model
- OSPF with the native model
- A static route
- Make it idempotent
- Delete, check, save
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
- devbox
eth0to Mgmt (network) - xe1
Gi1to Mgmt (network) - r1
Gi0/0to Mgmt (network) - xe1
Gi2to r1Gi0/1
| Node | Device | Image in Add Node | Set to |
|---|---|---|---|
| devbox | EVE-NG GUI server (Docker) | eve-gui-server:latest | 1 vCPU, 1,024 MB |
| xe1 | Cisco CSR 1000v | csr1000vng-universalk9.17.03.08a-serial | 1 vCPU, 4,096 MB |
| r1 | Cisco IOSv | vios-adventerprisek9-m.spa.159-3.m9 | 1 vCPU, 512 MB |
How to open this lab
Sign in to your workspace at
lab.cloudlabbox.com.In File Manager, open Shared, then the folder
Network Automation - CCNA and CCNP Automation guided labs.Open
10 - RESTCONF configuration management - desired state native models and idempotencyand 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
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.