Nornir CLI
Project description
nornir_cli
Documentation: https://timeforplanb123.github.io/nornir_cli
nornir_cli is CLI tool based on Nornir framework, Nornir Plugins and Click
Features
-
Simple CLI network orchestrator
nornir_cli
is a simple CLI orchestrator, that you can use to interact with the SoT and manage your network -
Workflow
nornir_cli
workflow isNornir
workflow, but from CLI -
Manage your custom nornir runbooks
- Create and manage your own nornir runbook collections:
- Add your custom nornir runbooks as custom commands in
nornir_cli
withrunbook collections
feature - Pass any python objects between custom commands
- Run custom commands for any hosts directly from the CLI
- Add your custom nornir runbooks as custom commands in
- Or use
nornir_cli
for inventory management only, and take the result in your nornir runbooks. By excluding getting and filtering the inventory in your runbooks, you will make them more versatile.
- Create and manage your own nornir runbook collections:
-
Manage Inventory
Get Inventory, filter Inventory, output Inventory and save Inventory state from the CLI for any inventory plugin. This is really useful for large, structured Inventory - for example, NetBox with nornir_netbox plugin.
You can use nornir_netbox or SimpleInventory, by default. Another inventory plugin needs to be installed from here with
pip
. -
Run Nornir Plugins
nornir_cli
already has commands, based on Nornir Plugins. Run them from the CLI, check result and statistic -
Build a chain of
nornir_cli
commandsInitialize Nornir, filter Inventory and run any command/command chains as one command
-
Json input. Json output
Json strings are everywhere! Ok, only in command options and arguments
-
Custom Multi Commands with click
nornir_cli
based on click Custom Multi Commands, so you can easily add your custom command by following some principles
Quick Start
Install
Please, at first, check the dependencies in pyproject.toml
and create new virtual environment if necessary and then:
with pip:
pip install nornir_cli
with git:
git clone https://github.com/timeforplanb123/nornir_cli.git
cd nornir_cli
pip install .
# or
poetry install
with Docker:
git clone https://github.com/timeforplanb123/nornir_cli.git
cd nornir_cli
docker build -t timeforplanb123/nornir_cli .
docker run --rm -it timeforplanb123/nornir_cli sh
# nornir_cli --version
nornir_cli, version 1.0.0
Simple Example
config.yaml
# Simple Nornir configuration file
inventory:
plugin: SimpleInventory
options:
host_file: "inventory/hosts.yaml"
hosts.yaml
# Single host inventory
dev_1:
hostname: 10.1.0.1
username: username
password: password
# huawei is just an example here
platform: huawei
nornir_cli
# As instance, let's run netmiko_send_command
$ nornir_cli nornir-netmiko init netmiko_send_command --command_string "display clock"
netmiko_send_command************************************************************
* dev_1 ** changed : False *****************************************************
vvvv netmiko_send_command ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
2021-03-17 14:04:22+03:00
Wednesday
Time Zone(Moscow) : UTC+03:00
^^^^ END netmiko_send_command ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
dev_1 : ok=1 changed=0 failed=0
OK : 1
CHANGED : 0
FAILED : 0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for nornir_cli-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c45d261a6be302e1c096c03c6474b36a18c527f2c46ea544ea776e1639865234 |
|
MD5 | ff2ee0a3fd2fc8ccbd9fdc577e30613a |
|
BLAKE2b-256 | 808d866ce82e05d3806d6deec2a024ff5fdf9a007e5b2c8cf78ce176c06fde78 |