Nornir

Installation

  • pip install nornir

Plugin Installation

  • pip install nornir_netbox

  • pip install nornir_napalm

  • pip install nornir_netmiko

Configuration

  • Inventory includes 3 files: hosts.yaml, groups.yaml and defaults.yaml

hosts.yml

---
host1.cmh:
    hostname: 127.0.0.1
    port: 2201
    username: vagrant
    password: vagrant
    platform: linux
    groups:
        - cmh
    data:
        site: cmh
        role: host
        type: host
        nested_data:
            a_dict:
                a: 1
                b: 2
            a_list: [1, 2]
            a_string: "asdasd"

host2.cmh:
    hostname: 127.0.0.1
    port: 2202
    username: vagrant
    password: vagrant
    platform: linux
    groups:
        - cmh
    data:
        site: cmh
        role: host
        type: host
        nested_data:
            a_dict:
                b: 2
                c: 3
            a_list: [1, 2]
            a_string: "qwe"

groups.yaml

defaults.yaml

Filtering

  • Using filter function for basic filtering

  • Using F function for advance filtering

Using Filter Function

Using plugins

Netbox

config.yaml

runbook.py

Napalm

Reference

  • https://theworldsgonemad.net/2021/nornir-basics/

  • https://theworldsgonemad.net/2021/nornir-inventory/

  • https://theworldsgonemad.net/2021/nornir-tasks/

  • https://ultraconfig.com.au/blog/nornir-framework-full-tutorial-for-beginners/

  • https://blogs.cisco.com/developer/nornir-python-automation-framework

  • https://nornir.readthedocs.io/en/latest/tutorial/index.html

  • https://nornir.tech/nornir/plugins/

  • https://blogs.cisco.com/developer/nornir-python-automation-framework

  • https://ultraconfig.com.au/blog/nornir-framework-full-tutorial-for-beginners/

  • https://theworldsgonemad.net/2021/nornir-basics/#task-options

  • https://pynet.twb-tech.com/blog/nornir-an-introduction.html

  • https://pynet.twb-tech.com/blog/nornir-using-ansible-inventory-part-1.html

  • https://www.packetcoders.io/how-to-build-a-network-automation-stack-with-nornir-napalm-and-netbox/

  • https://snyk.io/advisor/python/nornir/example

  • https://github.com/ThreeFDDI/nornir-netbox-demo/blob/master/nornir-netbox-demo.py

  • https://www.linkedin.com/pulse/peek-network-automation-using-python-nornir-jinja2-isolate-dadanema/

  • Nornir Filter: https://rayka-co.com/lesson/nornir-filter-inventory/

  • https://nornir.readthedocs.io/en/latest/howto/filtering_deep_dive.html

  • TextFSM parser: https://rayka-co.com/lesson/textfsm-parser-in-nornir-automation-scripts/

  • https://github.com/asadpoor/devnet/tree/master/pyhton_nornir

  • Nornir Script: Find Interfaces with CRC Errors: https://developer.cisco.com/codeexchange/github/repo/bsingh23/nornir_crc_errors/

Last updated