Skip to content

Setting up the environment#

To demonstrate the intent-based configuration management with Ansible we prepared a lab environment that you can set up on your own machine1. The lab environment consists of a small SR Linux-based Clos fabric that is going to be configured by Ansible using intents declared in the Ansible roles.

Prerequisites#

  • Readers should have a basic understanding of SR Linux and its network constructs to understand what this project does. Things like mac-vrfs, network instances, irb's, sub-interfaces, etc. should be familiar. For SR Linux newcomers we recommend first reading the SR Linux documentation to familiarize with the basic concepts.

  • Make sure Ansible (ansible-core) 2.9+ is installed. We recommend you run Ansible from a Python virtual environment, for example:

    Creating a venv and installing ansible-core
      python3 -m venv .venv
      source .venv/bin/activate
      pip install ansible-core
    
  • Ensure you have the Containerlab2 installed and are meeting its installation requirements.

  • We recommend you install the fcli tool that generates fabric-wide reports to verify things like configured services, interfaces, routes, etc.
    fcli is not required to run the project, but it's useful to verify the state of the fabric after running the playbook and is used throughout this tutorial to illustrate the effects of the Ansible playbooks.

    pip install -U nornir-srl
    

Installing the Ansible collection#

Install the SR Linux Ansible collection from Ansible Galaxy with the following command:

ansible-galaxy collection install nokia.srlinux

Clone the project repository#

The entire project is contained in the intent-based-ansible-lab repository. Following command will clone the repository to the current directory on your machine (in intent-based-ansible-lab directory):

git clone https://github.com/srl-labs/intent-based-ansible-lab.git
cd intent-based-ansible-lab

The following sections assume you are in the intent-based-ansible-lab directory.

Deploying the lab#

You need an SR Linux test topology to run the Ansible playbook and roles against. We will use Containerlab to create a lab environment with 6 SR Linux nodes: 4 leaves and 2 spines:

sudo containerlab deploy -c -t 4l2s.clab.yml

This will create a lab environment with 6 SR Linux nodes and a set of Linux containers to act as hosts:

Fabric topology

Containerlab populates the /etc/hosts file on the host machine with the IP addresses of the deployed nodes. This allows Ansible to connect to the nodes that has a matching inventory file inside the inv directory.

Verifying that all lab nodes are up and running
sudo containerlab inspect -t 4l2s.clab.yml

With the lab deployed, we can now explore the project's structure and understand the role's layout that powers the intent-based configuration management.


  1. As always, the lab is completely free to run, featuring our free and public SR Linux container image. 

  2. Using the version not older than the one mentioned in the tutorial summary section.