Overview
The IP Fabric Nornir plugin allows you to use your IP Fabric instance for your Nornir inventory.
Special Thanks
This project is an IP Fabric officially supported fork of nornir_ipfabric by routetonull
. Thank you for your work!
Install
The recommended way to install ipfabric_nornir
is via pip
:
pip install ipfabric_nornir
Requirements
An instance of IP Fabric is required for collecting information.
Example Usage
Setup
Using Environment Variables
Set environment variables to provide URL and credentials to connect to the IP Fabric server:
export IPF_URL=https://ipfabric.local
export IPF_TOKEN=myToken
# Or Username and Password
export IPF_USER=admin
export IPF_PASSWORD=mySecretPassword
Using .env
File
The easiest way to use this package is with a .env
file. You can copy the sample and edit it with your environment variables. An example file can be found at sample.env.
This contains the following variables which can also be set as environment variables instead of a .env
file.
IPF_URL="https://demo3.ipfabric.io"
IPF_TOKEN=TOKEN
IPF_VERIFY=true
Or if using Username/Password:
IPF_URL="https://demo3.ipfabric.io"
IPF_USERNAME=USER
IPF_PASSWORD=PASS
Running
from nornir import InitNornir
nr = InitNornir(inventory={"plugin": "IPFabricInventory"})
Using the InitNornir
Function
from nornir import InitNornir
nr = InitNornir(
inventory={
"plugin": "IPFabricInventory",
"options": {
"base_url": "https://ipfabric.local",
"token": "Token", # or "username":"admin", "password":"mySecretPassword",
"verify": True,
"platform_map": "netmiko", # "netmiko" (Default), "napalm", or "genie",
"default": {"username": "device_username", "password": "device_password"},
},
},
)
Using the Nornir Configuration File
config.yaml
file:
---
inventory:
plugin: IPFInventory
options:
base_url: "https://ipfabric.local"
token: "TOKEN"
# username: "admin"
# password: "mySecretPassword"
verify: true
platform_map: netmiko # "netmiko", "napalm", or "genie"
default:
username: "device_username"
password: "device_password"
Usage:
from nornir import InitNornir
nr = InitNornir(config_file="config.yaml", inventory={"plugin": "IPFabricInventory"})