Nornir vs Ansible
The main difference between Nornir and Ansible is that Nornir is a pure Python framework where everything you do is written in Python whilst Ansible which is also a Python based Framework requires you to write your playbooks in YAML. You do not need any Python knowledge to run Ansible, where you need to be quite knowledgeable in Python to run Nornir.
Nornir vs Ansible is a question I get asked all the time and it’s very valid, but whilst both are great network automation tools they both have their place depending on your use case and primarily skillset.
Nornir is an automation framework written in Python. Ansible is also an automation framework written in Python, however to use Nornir everything is driven from Python, whilst Ansible everything is driven by YAML playbooks.
While both tools tackle network automation tasks in a very different way Nornir is really for network engineers with a good understanding of Python, whilst Ansible requires no Python knowledge and is easier to get started with. Below I will discuss the pros and cons of each tool.
What is Nornir?
Nornir is a Python-based automation framework designed specifically for network automation tasks.
Nornir is 100% Python!
Nornir’s Core Capabilities
- Nornir is a flexible, scalable, and straightforward Python-based automation framework optimized for network automation.
- Nornir is pure Python so you are not dealing with a domain specific language like YAML so debugging is a lot easier.
- It is lean and does not rely on external daemons or databases, making it lightweight and fast.
- Nornir’s design philosophy revolves around being lightweight and direct, resulting in less overhead, faster execution, and fewer potential points of failure.
- Being Python-based, Nornir allows users to leverage the extensive Python ecosystem, libraries, and custom scripts.
- It offers a modular framework that allows integrating plugins or crafting bespoke solutions tailored to unique challenges.
- Nornir stands out for its distinct approach to network task automation, providing a unique combination of speed, scalability, and flexibility.
- Nornir is used primarlity for its speed, versatility, and ability to scrape data from hundreds of devices in seconds.
- It is favored by users comfortable with Python programming and manipulating Python output.
- However, Nornir’s reliance on Python programming can be a barrier for colleagues who are not programmers and prefer more user-friendly interfaces.
- Nornir is not inherently idempotent, requiring additional effort to implement a read, compare, write strategy for idempotency.
Nornir Use Cases
- Automating configuration backups and snapshots across network devices
Nornir can be used to create tasks that backup device configurations from routers, switches, firewalls etc. on a scheduled basis across your network infrastructure. This ensures you have up-to-date backups for auditing, compliance or recovery purposes. - Rendering and pushing configurations using templates
With Nornir’s integration with Jinja2 templates, you can pull data from sources like YAML files, render device configurations from templates, and then use plugins like NAPALM or Netmiko to push these configurations out to network devices. - Data collection and analysis
Nornir allows you to run show commands or gather operational data from network devices in parallel. This data can then be analyzed, processed and fed into other systems for monitoring, reporting or troubleshooting purposes. - Network validation and compliance checks
You can build Nornir tasks to validate device configurations against defined policies/standards and identify any deviations. This ensures network-wide configuration consistency. - Zero-touch provisioning and deployment
Nornir’s inventory capabilities combined with its task execution framework enables zero-touch provisioning of new network devices by automatically deploying configurations during device rollouts or replacements.
The multi-vendor support, parallelism, extensibility through plugins, and the ability to integrate with tools like NetBox make Nornir a powerful framework for automating a wide variety of network operations and workflows
Ansible vs Nornir
Ansible vs Nornir
What is Ansible?
Ansible’s Key Features
Nornir vs Ansible: Speed and Performance
Nornir vs Ansible: Infrastructure Management
Nornir and NetBox Integration
Nornir can integrate with NetBox through the use of the nornir_netbox library or plugin. Here are some key points about the Nornir-NetBox integration: Nornir allows you to pass configuration options like the NetBox URL when initializing it, for example:
nr = InitNornir( inventory={ "plugin":"NetBoxInventory2", "options": { "nb_url": "https://netbox.local:8000", "nb_token": "1234567890" } } )
This allows Nornir to connect to the specified NetBox instance. The nornir_netbox library provides a NetBoxInventory2 plugin that allows you to retrieve NetBox data like device and virtual machine information.
It exposes configuration options like the NetBox URL and API token. The nornir_netbox library is a separate library or plugin that facilitates the Nornir-NetBox integration, allowing you to pass in options like the NetBox URL and API token when initializing Nornir.
In summary, by leveraging the nornir_netbox library or plugin, you can integrate Nornir with NetBox and access NetBox data within your Nornir scripts or workflows. This integration enables you to utilise NetBox as a centralized source of truth for network data while taking advantage of Nornir’s capabilities for executing tasks or scripts against that data
Leave a Reply