Nornir went through a pretty big change going from version 2 to version 3. It feels like they are moving more toward the Ansible model of development with the core service as its own project and everything else is a plugin. This seems to be for the better. Anyway, this changed a lot of the configuration and import statements you may find in older posts or documentation.
Here is a basic configuration file with the updated inventory plugin name for simple inventory.
config.yaml
---
inventory:
plugin: SimpleInventory
options:
host_file: "inventory/hosts.yaml"
group_file: "inventory/groups.yaml"
defaults_file: "inventory/defaults.yaml"
runner:
plugin: threaded
options:
num_workers: 20
#plugin: serial
core:
raise_on_error: False
Here is a base groups.yaml file that I like to start with to define all the connection options on a group level. From here just assign each host to one of these groups.
groups.yaml
---
ios:
connection_options:
netmiko:
platform: cisco_ios #SSH
napalm:
platform: ios #SSH
nxos:
connection_options:
netmiko:
platform: cisco_nxos #SSH
napalm:
platform: nxos #API
ciscosmb:
connection_options:
netmiko:
platform: cisco_s300 #SSH
junos:
connection_options:
netmiko:
platform: juniper_junos #SSH (Not NETCONF)
napalm:
platform: junos #Netconf
eos:
connection_options:
netmiko:
platform: arista_eos #SSH
napalm:
platform: eos #API
And here are some of the common plugins and functions that you may find yourself needing to import into your code when using the Nornir framework.
sample_code.py
# Nornir Core
from nornir import InitNornir
from nornir.core.filter import F
#Napalm
from nornir_napalm.plugins.tasks import napalm_get
from nornir_napalm.plugins.tasks import napalm_cli
from nornir_napalm.plugins.tasks import napalm_configure
from nornir_napalm.plugins.tasks import napalm_ping
from nornir_napalm.plugins.tasks import napalm_validate
#Netmiko
from nornir_netmiko import netmiko_send_command
from nornir_netmiko import netmiko_send_config
from nornir_netmiko import netmiko_save_config
from nornir_netmiko import netmiko_file_transfer
#Others
from nornir_utils.plugins.functions import print_result
from nornir_jinja2.plugins.tasks import template_file