top of page

An Automation Platform for Nornir

  • steve291030
  • May 7
  • 1 min read

Updated: May 8

Kriten can run any code that can be containerised, and make it available to run via an API call.

ree

Try it out on a laptop - full instructions

Clone or fork the kriten toolkit repo and setup the venv

git clone https://github.com/kriten-io/kriten-community-toolkit.git
cd kriten-community-toolkit/nornir
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Change the values in the nornir/inventory folder. In this example we have four Arista switches in two groups, LEAF and SPINE.


ree

Kriten takes parameters from an environment variable called EXTRA_VARS. So if you want to test your script works locally, export the vars, eg:

export EXTRA_VARS='{"group": "LEAF"}'
python3 sh-ip-int.py

Push the code to your own git repo.

If you have followed the install Kriten on a macbook article, you should be able to browse to http://"$IP_ADDRESS":30050


Login (default credentials root:root) and add a runner and task:


The image in the example is one we created with Nornir 3.5.0 installed.


ree


ree

Create the job. Extra vars are optional.


You can also run the job from a terminal using curl:

export IP_ADDRESS=<your_ip_address>

curl -c ./token.txt -X POST 'http://'$IP_ADDRESS':30040/api/v1/login' \
--header 'Content-Type: application/json' \
--data '{
  "username": "root",
  "password": "root",
  "provider": "local"
}' 

curl -b ./token.txt -X POST 'http://'$IP_ADDRESS':30040/api/v1/jobs/nornir-sh-ip-int' \
--header 'Content-Type: application/json' \
--data '{
  "group": "LEAF"
}'

Use the job id to view the output:

curl -b ./token.txt -X GET 'http://'$IP_ADDRESS':30040/api/v1/jobs/nornir-sh-ip-int-xxxxx/log' \
--header 'Content-Type: application/json'

 
 
bottom of page