What is Nornir? Why Should You ‘Break Up’ with Ansible for Nornir?
If you’ve worked in Network Automation, you’ve likely used Ansible. Ansible is great, but when scaling systems to thousands of devices, it starts to show its weaknesses. Slow execution speeds and rigid YAML syntax often make handling complex logic a nightmare. That’s where Nornir shines.
At its core, Nornir is not a standalone tool but a pure Python framework. You can leverage the entire Python ecosystem, such as Pandas for data processing or Requests for API calls, directly within your scripts. Debugging also becomes more intuitive because you’re working with code, not just plain text configuration files.
Quick Start: Running Your First Script in 5 Minutes
First, install Nornir along with the Netmiko plugin to interact with devices via SSH.
pip install nornir nornir_utils nornir_netmiko
Nornir’s inventory typically consists of 3 YAML files for device management. Prepare the following files in your project directory:
1. config.yaml (System Configuration)
inventory:
plugin: SimpleInventory
options:
host_file: "hosts.yaml"
group_file: "groups.yaml"
runner:
plugin: threaded
options:
num_workers: 20
2. groups.yaml (Group Management)
ios_devices:
platform: cisco_ios
username: admin
password: YourPassword123
3. hosts.yaml (Specific Device List)
sw-access-01:
hostname: 192.168.1.10
groups:
- ios_devices
sw-access-02:
hostname: 192.168.1.11
groups:
- ios_devices
4. Python Execution Script (main.py)
The script below will connect to devices simultaneously to retrieve software version information.
