Table of contents:
This repository showcases our SR Linux module and has a few examples to get you started with Inmanta.
The provided examples in the *.cf files can be applied on SR Linux devices either on:
-
A device that you already have and by changing the IP address, port, etc... in the examples files
-
Or using containerlab with the provided topology file.
Install containerlab using this link
In case of choosing the containerlab option, it is worthwhile to mention that you need to have a SR Linux Docker image present on the host machine running containerlab and having it tagged similar to the topology file; in this case: ghcr.io/nokia/srlinux.
The SR Linux docker image can be pulled using:
sudo docker pull ghcr.io/nokia/srlinuxFurthermore, if the SR Linux docker image is missing on your machine, it will be pulled by the Containerlab automatically.
The SR Linux topology alongside the IP addresses is depicted as follows:
Inmanta Service Orchestrator is another containerized piece that can supply a GUI, providing many useful information such as deployment process, agents status and so much more. This container can be manually pulled by:
sudo docker pull ghcr.io/inmanta/orchestrator:latestNOTE: This container will automatically get pulled by Containerlab if you skip the command above.
In order to deploy the provided topology file with containerlab go to the containerlab folder where the topology file is present and run:
cd containerlab
sudo clab deploy -t topology.ymlThis command will spin-up three SR Linux containers, an Inmanta server and a PostgreSQL container.
Note: It will take a few seconds up to minutes to fully boot-up the containers depending on your system horsepower.
Open up a browser and connect to the Inmanta container using this URL http://172.30.0.3:8888.
After connecting to the Inmanta container, you can create a new environment by clicking on the Create new environment button. Then you need to copy the environment ID either:
- from the URL, e.g.
ec05d6d9-25a4-4141-a92f-38e24a12b721from thehttp://172.30.0.3:8888/console/desiredstate?env=ec05d6d9-25a4-4141-a92f-38e24a12b721. - or by clicking on the gear icon on the top right of the Web Console, then click on
Environment, scroll down all the way to the bottom of the page and copy the environment ID.
Additionally, you can prepare a development environment and achieve the same goal through
inmanta-cliby referring to the last section of additional commands
You can connect to the containers in two ways:
-
Using Docker:
docker exec -it clab-srlinux-spine sr_cli # or docker exec -it clab-srlinux-leaf1 sr_cli # or docker exec -it clab-srlinux-leaf2 sr_cli
-
Using SSH (username and password are
admin):ssh admin@clab-srlinux-spine ssh admin@clab-srlinux-leaf1 ssh admin@clab-srlinux-leaf2
Then enter the configuration mode by typing:
enter candidateThe output should look something like this:
Welcome to the srlinux CLI.
Type 'help' (and press <ENTER>) if you need any help using this.
--{ running }--[ ]--
A:spine#In order to run the provided examples, you need to prepare a development environment using Python 3.12 by creating a Python virtual environment and installing the required packages:
Check the current Python version:
$ python3 --version
Python 3.12.8Create a virtual environment and install Inmanta:
python3 -m venv ~/.virtualenvs/srlinux
source ~/.virtualenvs/srlinux/bin/activate
pip install inmantaInstall the project:
inmanta project installAnd then, compile the main.cf file to make sure you have all the required packages:
inmanta compile -f main.cfWhen
inmanta compileis run by itself, the implicit behavior is that it always compiles themain.cffile. Hence, the command above could simply beinmanta compile.
After that, export a model to the server. For example, interfaces.cf:
inmanta -vvv export -f interfaces.cf -e <environment_id> --server_address 172.30.0.3NOTE: Please make sure to swap the
<environment_id>with your own environment id.
Deploy the LAB:
sudo clab deploy -t topology.ymlView the current LAB state:
sudo clab inspect -t topology.ymlDelete the deployed LAB:
sudo clab destroy -t topology.ymlExport the model to Inmanta server:
inmanta -vvv export -f main.cf -e <environment_id> --server_address 172.30.0.3
# or
inmanta -vvv export -f interfaces.cf -e <environment_id> --server_address 172.30.0.3
# or
inmanta -vvv export -f ospf.cf -e <environment_id> --server_address 172.30.0.3Create a project and an environment (test and SR_Linux respectively):
inmanta-cli --host 172.30.0.3 project create -n test
inmanta-cli --host 172.30.0.3 environment create -p test -n SR_Linux --saveBy using the inmanta-cli command, you can omit the environment id and server ip address from the inmanta export command:
inmanta -vvv export -f main.cf
# or
inmanta -vvv export -f interfaces.cf
# or
inmanta -vvv export -f ospf.cfFree up the taken disk space by Docker using:
sudo docker system pruneRemove the Docker images:
sudo docker rmi -f ghcr.io/inmanta/orchestrator:latest
sudo docker rmi -f ghcr.io/nokia/srlinux:latest
sudo docker rmi -f postgres:13