-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f274f96
Showing
29 changed files
with
4,143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: docs | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.x | ||
- run: pip install mkdocs-material | ||
- run: mkdocs gh-deploy --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Distribution / packaging | ||
build/ | ||
wheels/ | ||
sdist/ | ||
dist/ | ||
|
||
# Service files | ||
config.yaml | ||
nornir.log | ||
.temp.pkl | ||
|
||
*.swp | ||
nornir_cli/__pycache__/ | ||
nornir_cli/*.swp | ||
|
||
nornir_cli/**/__pycache__/ | ||
nornir_cli/**/*.swp | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM python:3.8-slim-buster | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
RUN pip3 install . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Pavel Shemetov | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) | ||
|
||
nornir_cli | ||
========== | ||
|
||
--- | ||
|
||
**Documentation**: <a href="https://timeforplanb123.github.io/nornir_cli" target="_blank">https://timeforplanb123.github.io/nornir_cli</a> | ||
|
||
--- | ||
|
||
**nornir_cli** is CLI tool based on <a href="https://github.com/nornir-automation/nornir" target="_blank">Nornir framework</a>, | ||
<a href="https://nornir.tech/nornir/plugins/" target="_blank">Nornir Plugins</a> and <a href="https://github.com/pallets/click" target="_blank">Click</a> | ||
|
||
|
||
## Features | ||
|
||
* **Manage your custom nornir runbooks** | ||
|
||
Add custom nornir runbook to the `nornir_cli` `custom` group and run it for any hosts directly from the CLI | ||
|
||
* **Manage Inventory** | ||
|
||
Get Inventory, filter Inventory, output Inventory and save Inventory state from the CLI. | ||
This is really useful for large, structured Inventory - for example, <a href="https://github.com/netbox-community/netbox" target="_blank">NetBox</a> with <a href="https://github.com/wvandeun/nornir_netbox" target="_blank">nornir_netbox plugin</a>. | ||
|
||
* **Run Nornir Plugins** | ||
|
||
Run Tasks based on Nornir Plugins from the CLI, check result and statistic | ||
|
||
* **Build a chain of `nornir_cli` commands** | ||
|
||
Initialize Nornir, filter Inventory and start Task/Tasks chains or runbook/runbooks chains in one command | ||
|
||
* **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:** | ||
|
||
```text | ||
pip install nornir_cli | ||
``` | ||
|
||
**with git:** | ||
|
||
```text | ||
git clone https://github.com/timeforplanb123/nornir_cli.git | ||
cd nornir_cli | ||
pip install . | ||
# or | ||
poetry install | ||
``` | ||
|
||
**with Docker:** | ||
|
||
```text | ||
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 0.1.0 | ||
``` | ||
|
||
#### Simple Example | ||
|
||
|
||
#### config.yaml | ||
```yaml | ||
# Simple Nornir configuration file | ||
inventory: | ||
plugin: SimpleInventory | ||
options: | ||
host_file: "inventory/hosts.yaml" | ||
``` | ||
#### hosts.yaml | ||
```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 | ||
```text | ||
# 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 | ||
``` |
Oops, something went wrong.