MAY 28, 2024

SUHAIB SAEED

Introduction

This blog post will run through the basics of the Nornir Network Automation Framework. We’ll also contrast it with Ansible and speak about the pros and cons of each. Some basic knowledge of Python, Ansible and network automation libraries such as Netmiko is assumed.

Those of you that know me well will be aware that I have some very strong opinions about this topic. Having said that, I’ll try my level best to approach this from an objective lens.

What is Nornir?

Nornir is an extremely fast and highly pluggable pure-python network automation framework created by David Barroso (the creator of NAPALM) & Kirk Byers (the creator of Netmiko).

A good place to start is to talk about what problem we’re trying to solve. Some you may be thinking why do we even need to bother using frameworks in the first place and what’s wrong with just creating a normal Python script?

A common consideration we usually have in network automation is managing related variables. This may be things such as NTP servers, IP addresses, or BGP AS numbers to name a few. It will be tempting to just hard code everything within the script itself, but what happens when we need to share this script with others or re-use it in the future? We’d have to change the script each time, which can get very messy and harder to version control.

Another issue is the scalability of our scripts. We might only need to run it against one or two devices at first but what happens when we now need to run it on tens or even hundreds of devices. This may entail re-working our code once again and will add several magnitudes of execution time to the script. Also, what happens if we only want to run our script on devices only at a particular site now, would it be a case of changing our code yet again?

All of the problems mentioned above are things that the Nornir framework helps us with. Automation is broken down into tasks (like Ansible does in YAML) but are written in 100% Python and are also run against devices concurrently, speeding up execution time. It also gives us a systematic approach to our inventory and related data/variables, again which is similar to Ansible’s approach.

Nornir Vs Ansible

We’ve already mentioned a few times that Nornir is similar to Ansible in some ways, it would be fair to describe the two tools as being closely related cousins. Let’s compare both and go through the benefits and drawbacks of each.

Pros

Nornir Pros

Ansible Pros

Cons

Nornir Cons

Ansible Cons