This repository contains the resources for building and managing an network automation stack within a network lab environment, specifically designed for the "Network Automation Cookbook 2nd edition" book.
The lab environments are designed to set up a small network and an attached automation stack. Developed and tested on Debian-based systems, we provide setup documentation to guide you through automatic setup on a DigitalOcean droplet. This process will provision, install dependencies, and configure the environment automatically. But if you want to host the lab environment, ensure the following:
dockerinstalled (version26.1.1or above)containerlabfor the network lab (version0.54.2or above)labfor managing the network and lab stack- Arista
cEOSimages for thecontainerlabenvironment. You can open an account and download them at arista.com
For detailed setup instructions, please refer to the setup README. It provides a comprehensive guide on installing the lab environment on a DigitalOcean Droplet.
After downloading the image, use the following command to import them as Docker images:
# Import cEOS images as Docker images
docker import <path-to-image>/cEOS64-lab-<version>.tar.xz ceos:imageTo get started with the network lab stack, you need to:
- Copy the necessary environment variables to configure the components used within the lab scenarios.
# Setup environment variables (edit the .env file to your liking)
cp example.env .env- Install the
labutility command that helps manage the entire lab environment. Example usinguv:
# Install the python dependencies
uv pip install .- Test everything is working by deploying a lab that has most of the components configured and ready to go.
# Start the network lab
lab lab deploy --scenario batteries-includedNOTE: Our lab comes with a
batteries-includedsetup, providing you with everything you need to get started with network lab right away. This setup includes pre-configured tools and detailed step-by-step instructions to help you explore and learn without any hassle. Head over to the instructions section to begin!
The lab utility tool simplifies managing and monitoring the network lab and other stack set up within this repository. It provides a suite of commands designed to streamline various tasks associated with your network infrastructure.
The lab utility includes five main commands to help manage the environment:
-
lab setup: Manages the overall setup of a remote DigitalOcean droplet hosting this repository and its lab environment. This command simplifies the process of preparing a hosting environment for users. -
lab containerlab: Manages thecontainerlabpre-configured setup. All lab scenarios presented in the chapters operate under this network lab configuration. -
lab docker: Manages the Docker Compose setups for each lab scenario. It ensures the appropriate containers are running for each specific lab exercise.
For instance, the lab lab deploy command builds and starts a containerlab environment along with the automation stack. This command sets up the entire lab scenario, ensuring that all necessary components are up and running.
# Start the network lab
❯ lab lab deploy batteries-included --sudo
[21:50:42] Deploying lab environment
Network create: network-cookbook-lab
Running command: docker network create --driver=bridge --subnet=198.51.100.0/24 network-cookbook-lab
Successfully ran: network create
─────────────────────────────────────────────────── End of task: network create ────────────────────────────────────────────────────
Deploying containerlab topology
Topology file: containerlab/lab.yml
Running command: sudo containerlab deploy -t containerlab/lab.yml
INFO[0000] Creating container: "ceos-01"
INFO[0000] Creating container: "ceos-02"
INFO[0001] Creating virtual wire: ceos-01:eth2 <--> ceos-02:eth2
INFO[0001] Creating virtual wire: ceos-01:eth1 <--> ceos-02:eth1
+---+---------+--------------+----------------+------+---------+------------------+--------------+
| # | Name | Container ID | Image | Kind | State | IPv4 Address | IPv6 Address |
+---+---------+--------------+----------------+------+---------+------------------+--------------+
| 1 | ceos-01 | d59629fbbdc0 | ceos:4.28.5.1M | ceos | running | 198.51.100.11/24 | N/A |
| 2 | ceos-02 | 80854bfd7e08 | ceos:4.28.5.1M | ceos | running | 198.51.100.12/24 | N/A |
+---+---------+--------------+----------------+------+---------+------------------+--------------+
[21:51:14] Successfully ran: Deploying containerlab topology
─────────────────────────────────────────── End of task: Deploying containerlab topology ───────────────────────────────────────────
Running command: docker compose --project-name lab -f chapters/docker-compose.yml --verbose up -d --remove-orphans
[+] Building 0.0s (0/0)
[+] Running 10/10
... too be updated ..
[21:51:16] Successfully ran: start stack
───────────────────────────────────────────────────── End of task: start stack ─────────────────────────────────────────────────────Here is a brief overview of the practical chapters and the key concepts you will encounter:
Batteries IncludedScenario: This scenario brings everything together in a fully configured environment, offering a glimpse into the full potential of these tools. The batteries-included scenario README provides an overview and detailed explanation of the setup, giving you a holistic view of what is achievable with this setup.