Registry / devops / nornir

nornir

JSON →
library3.5.0pypypi✓ verified 85d ago

Nornir is a pluggable multi-threaded automation framework with inventory management for operating collections of network devices. It provides a pure Python approach to network automation without relying on a DSL. Current version is 3.5.0 (2024-09-16), released several times a year.

pip install nornir
INSTALL
IMPORT
SIG · NORNIR
N
nornir
devopspythonv3.5.0
Install
2.2s avg
Import
182ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.190s · 19.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.2s · import 0.174s · 20MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

InitNornir
from nornir import InitNornir
from nornir.core import InitNornir
InitNornir is in the top-level nornir package since v3.0.
NRF
from nornir.plugins.functions import NRF
Filter
from nornir.core.filter import F
from nornir import Filter
The F class is used for filtering hosts.

Basic example: initialize Nornir with an inline dict inventory, run a simple task, and print the result.

from nornir import InitNornir from nornir.core.task import Task, Result # Create a simple inventory definition inline nr = InitNornir( inventory={ "plugin": "DictInventory", "options": { "hosts": { "router1": { "hostname": "192.0.2.1", "username": "admin", "password": "password" } } } } ) # Define a task def hello_task(task: Task) -> Result: return Result(host=task.host, result=f"Hello from {task.host.name}") # Run the task results = nr.run(task=hello_task) print(results['router1'][0].result) # Close connections if any nr.close_connections()
nornir --version
Debug
Known issues
breakingNornir 3.x introduced a completely new API compared to 2.x. The `InitNornir` function, inventory structure, and task execution model changed significantly. Existing Nornir 2.x code will not work without migration.
fix
Follow the official upgrade guide at https://nornir.readthedocs.io/en/latest/upgrading/2_to_3.html
affects: 3.0.0+
gotchaNornir's default runner is `ThreadedRunner`, which uses threading. This may cause issues with libraries that are not thread-safe (e.g., some SSH libraries).
fix
Use the `SerialRunner` to run tasks sequentially: `InitNornir(runner={'plugin': 'SerialRunner'})`
affects: 3.x
deprecatedThe `ParallelRunner` plugin was renamed to `ThreadedRunner` in v3.0.0a4. Using `ParallelRunner` will raise a deprecation warning.
fix
Use `'plugin': 'ThreadedRunner'` instead of `'plugin': 'ParallelRunner'`
affects: 3.0.0+
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'nornir'
Nornir is not installed.
fix
Run `pip install nornir`
nornir.core.exceptions.NornirUnsupportedConfigSchema: Unsupported config schema
The configuration dictionary passed to InitNornir does not match the expected schema (e.g., using a plugin not recognized).
fix
Ensure you are using the correct plugin names and options as per Nornir 3 documentation. For DictInventory, use `inventory={'plugin': 'DictInventory', 'options': {...}}`
AttributeError: 'str' object has no attribute 'name'
In Nornir 3, task function should accept a `Task` object, not a hostname string. The first argument is the task instance, and the host is accessed via `task.host`.
fix
Define your task function like: `def my_task(task: Task) -> Result: host = task.host`
AttributeError: 'Nornir' object has no attribute 'run'
Using Nornir 2.x style `nr.run()`. In Nornir 3, the method is `nr.run()` but the task function signature changed. If you see this error, you might be using an old version or mixing APIs.
fix
Ensure you are using Nornir 3.x and that your task function is defined correctly (accepts a single `task` argument).
Upgrade
Version history
3.5.0latest on PyPI · released Jan 8, 2025
Audit
Dependencies
nornir-utilsoptionalProvides common tasks like netmiko_send_command, napalm_get, etc.
Agent activity
4 hits · last 30 days
node
4
Resources
nornir — pip install nornir · libregistry