A practical example of using Ansible to manage the configuration of an SR Linux fabric with the intent-based approach leveraging the official Ansible collection for SR Linux - read the tutorial on learn.srlinux.dev for a complete walkthrough of this project.
Run this lab in GitHub Codespaces for free.
Learn more about Containerlab for Codespaces.
- Codespaces: click the button above and wait for the devcontainer to finish. Everything below is run from the repo root inside Codespaces.
- Local machine: follow the prerequisites and setup below, then run the same workflow.
- Containerlab installed. See the official docs.
- Git, Docker, and uv.
Tip
Why uv?
uv is a single, ultra-fast tool that can replace pip, pipx, virtualenv, pip-tools, poetry, and more. It automatically manages Python versions, handles ephemeral or persistent virtual environments (uv venv), lockfiles, and often runs 10–100× faster than pip installs.
# Install uv (Linux/macOS)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install the Nokia SR Linux Ansible collection
uv run ansible-galaxy collection install nokia.srlinux
# Install the fcli tool
uv tool install git+https://github.com/srl-labs/nornir-srl- Deploy the lab topology:
clab deploy -t topo.clab.yml
- Run the Ansible playbook:
INTENT_DIR=$(pwd)/intent_examples/infra/underlay_with_fabric_intent
uv run ansible-playbook -i inv/ -e intent_dir=$INTENT_DIR --diff playbooks/cf_fabric.yml
- Verify with fcli
fcli -t topo.clab.yml ni
- Run other Ansible playbook described here:
https://learn.srlinux.dev/tutorials/programmability/ansible/intent-based-management/config/