diff --git a/README.rst b/README.rst
index acd8ddd..6ae9cd0 100644
--- a/README.rst
+++ b/README.rst
@@ -29,10 +29,17 @@ _________
Functions
_________
-* **print_result** - formats nicely and prints results on stdout
-* **print_title** - formats nicely a title and prints it on stdout
+* **print_result** - Formats nicely and prints results on stdout.
+* **print_title** - Formats nicely a title and prints it on stdout.
Processors
__________
-* **PrintResult** - formats nicely and prints results on stdoud as soon as they are made available
+* **PrintResult** - Formats nicely and prints results on stdout as soon as they are made available.
+
+Data
+__________
+
+* **echo_data** - Dummy task that echoes the data passed to it.
+* **load_json** - Load a JSON file.
+* **load_yaml** - Load a YAML file.
diff --git a/docs/doctrees/api/functions.doctree b/docs/doctrees/api/functions.doctree
index fd014f3..bd731f1 100644
Binary files a/docs/doctrees/api/functions.doctree and b/docs/doctrees/api/functions.doctree differ
diff --git a/docs/doctrees/api/index.doctree b/docs/doctrees/api/index.doctree
index 32d36fd..1dabb69 100644
Binary files a/docs/doctrees/api/index.doctree and b/docs/doctrees/api/index.doctree differ
diff --git a/docs/doctrees/api/inventory.doctree b/docs/doctrees/api/inventory.doctree
index 7025a12..d7605b7 100644
Binary files a/docs/doctrees/api/inventory.doctree and b/docs/doctrees/api/inventory.doctree differ
diff --git a/docs/doctrees/api/processors.doctree b/docs/doctrees/api/processors.doctree
index 451b5b1..2c119a3 100644
Binary files a/docs/doctrees/api/processors.doctree and b/docs/doctrees/api/processors.doctree differ
diff --git a/docs/doctrees/api/tasks.doctree b/docs/doctrees/api/tasks.doctree
new file mode 100644
index 0000000..964956c
Binary files /dev/null and b/docs/doctrees/api/tasks.doctree differ
diff --git a/docs/doctrees/environment.pickle b/docs/doctrees/environment.pickle
index e758165..62b866f 100644
Binary files a/docs/doctrees/environment.pickle and b/docs/doctrees/environment.pickle differ
diff --git a/docs/doctrees/index.doctree b/docs/doctrees/index.doctree
index 4ba67d3..2cb7269 100644
Binary files a/docs/doctrees/index.doctree and b/docs/doctrees/index.doctree differ
diff --git a/docs/doctrees/nbsphinx/tutorials/echo_data.ipynb b/docs/doctrees/nbsphinx/tutorials/echo_data.ipynb
new file mode 100644
index 0000000..6526c8a
--- /dev/null
+++ b/docs/doctrees/nbsphinx/tutorials/echo_data.ipynb
@@ -0,0 +1,99 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": false
+ },
+ "source": [
+ "# echo_data\n",
+ "\n",
+ "echo_data is a data plugin that echoes the data passed into it. It is useful in grouped_tasks debugging.\n",
+ "\n",
+ "## Example"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\u001b[1m\u001b[36mgrouped_task********************************************************************\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[34m* dev1.group_1 ** changed : False **********************************************\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[32mvvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[32m---- dev1.group_1 ** changed : False ------------------------------------------- INFO\u001b[0m\n",
+ "\u001b[0m{'role': 'www'}\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[32m^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[34m* dev2.group_1 ** changed : False **********************************************\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[32mvvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[32m---- dev2.group_1 ** changed : False ------------------------------------------- INFO\u001b[0m\n",
+ "\u001b[0m{'role': 'db'}\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[32m^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[34m* dev3.group_2 ** changed : False **********************************************\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[32mvvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[32m---- dev3.group_2 ** changed : False ------------------------------------------- INFO\u001b[0m\n",
+ "\u001b[0m{'role': 'www'}\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[32m^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[34m* dev4.group_2 ** changed : False **********************************************\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[32mvvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[32m---- dev4.group_2 ** changed : False ------------------------------------------- INFO\u001b[0m\n",
+ "\u001b[0m{'role': 'db'}\u001b[0m\n",
+ "\u001b[0m\u001b[1m\u001b[32m^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001b[0m\n",
+ "\u001b[0m"
+ ]
+ }
+ ],
+ "source": [
+ "from nornir import InitNornir\n",
+ "from nornir.core.filter import F\n",
+ "from nornir_utils.plugins.tasks.data import echo_data\n",
+ "from nornir_utils.plugins.functions import print_result\n",
+ "\n",
+ "nr = InitNornir(\n",
+ " inventory={\n",
+ " \"plugin\": \"SimpleInventory\",\n",
+ " \"options\": {\"host_file\": \"data/hosts.yaml\", \"group_file\": \"data/groups.yaml\"},\n",
+ " }\n",
+ ")\n",
+ "nr = nr.filter(~F(name=\"dev5.no_group\"))\n",
+ "\n",
+ "\n",
+ "def grouped_task(task):\n",
+ " task.run(task=echo_data, name=task.host.name, role=task.host[\"role\"])\n",
+ "\n",
+ "\n",
+ "r = nr.run(task=grouped_task)\n",
+ "print_result(r)"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.8.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/docs/doctrees/nbsphinx/tutorials/function_print_result.ipynb b/docs/doctrees/nbsphinx/tutorials/function_print_result.ipynb
index 57cac67..e284ae5 100644
--- a/docs/doctrees/nbsphinx/tutorials/function_print_result.ipynb
+++ b/docs/doctrees/nbsphinx/tutorials/function_print_result.ipynb
@@ -22,7 +22,7 @@
"\n",
"nr = InitNornir(\n",
" inventory={\n",
- " \"plugin\":\"SimpleInventory\",\n",
+ " \"plugin\":\"YAMLInventory\",\n",
" \"options\": {\n",
" \"host_file\": \"data/hosts.yaml\",\n",
" \"group_file\": \"data/groups.yaml\",\n",
diff --git a/docs/doctrees/nbsphinx/tutorials/inventory_SimpleInventory.ipynb b/docs/doctrees/nbsphinx/tutorials/inventory_YAMLInventory.ipynb
similarity index 97%
rename from docs/doctrees/nbsphinx/tutorials/inventory_SimpleInventory.ipynb
rename to docs/doctrees/nbsphinx/tutorials/inventory_YAMLInventory.ipynb
index b5398ca..5a2e96c 100644
--- a/docs/doctrees/nbsphinx/tutorials/inventory_SimpleInventory.ipynb
+++ b/docs/doctrees/nbsphinx/tutorials/inventory_YAMLInventory.ipynb
@@ -4,10 +4,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# inventory: SimpleInventory\n",
+ "# inventory: YAMLInventory\n",
"\n",
"\n",
- "[SimpleInventory](../api/inventory.rst#nornir_utils.plugins.inventory.SimpleInventory) is an inventory plugin that builds the inventory from a few YAML files.\n",
+ "[YAMLInventory](../api/inventory.rst#nornir_utils.plugins.inventory.YAMLInventory) is an inventory plugin that builds the inventory from a few YAML files.\n",
"\n",
"## Data\n",
"\n",
@@ -203,7 +203,7 @@
"source": [
"## Example\n",
"\n",
- "Once you have the yaml files, using the plugin is very simple, you just need to specify the plugin you want to use is `SimpleInventory` and where to find the files:"
+ "Once you have the yaml files, using the plugin is very simple, you just need to specify the plugin you want to use is `YAMLInventory` and where to find the files:"
]
},
{
@@ -216,7 +216,7 @@
"\n",
"nr = InitNornir(\n",
" inventory={\n",
- " \"plugin\":\"SimpleInventory\",\n",
+ " \"plugin\":\"YAMLInventory\",\n",
" \"options\": {\n",
" \"host_file\": \"data/hosts.yaml\",\n",
" \"group_file\": \"data/groups.yaml\",\n",
diff --git a/docs/doctrees/nbsphinx/tutorials/load_json.ipynb b/docs/doctrees/nbsphinx/tutorials/load_json.ipynb
new file mode 100644
index 0000000..fadb9d6
--- /dev/null
+++ b/docs/doctrees/nbsphinx/tutorials/load_json.ipynb
@@ -0,0 +1,99 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": false
+ },
+ "source": [
+ "# load_json\n",
+ "\n",
+ "Loads a JSON file.\n",
+ "\n",
+ "## Example"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev1.group_1\n",
+ "JSON data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev2.group_1\n",
+ "JSON data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev3.group_2\n",
+ "JSON data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev4.group_2\n",
+ "JSON data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev5.no_group\n",
+ "JSON data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n"
+ ]
+ }
+ ],
+ "source": [
+ "from nornir import InitNornir\n",
+ "from nornir_utils.plugins.tasks.data import load_json\n",
+ "\n",
+ "nr = InitNornir(\n",
+ " inventory={\n",
+ " \"plugin\": \"SimpleInventory\",\n",
+ " \"options\": {\"host_file\": \"data/hosts.yaml\", \"group_file\": \"data/groups.yaml\"},\n",
+ " }\n",
+ ")\n",
+ "\n",
+ "r = nr.run(task=load_json, file=\"data/ip_addresses.json\")\n",
+ "for host, m_result in r.items():\n",
+ " print()\n",
+ " print(\"-\" * 40)\n",
+ " print(f\"Host: {host}\")\n",
+ " print(f\"JSON data: {m_result.result}\")\n",
+ " print(\"-\" * 40)"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.8.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/docs/doctrees/nbsphinx/tutorials/load_yaml.ipynb b/docs/doctrees/nbsphinx/tutorials/load_yaml.ipynb
new file mode 100644
index 0000000..e03a1bb
--- /dev/null
+++ b/docs/doctrees/nbsphinx/tutorials/load_yaml.ipynb
@@ -0,0 +1,99 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": false
+ },
+ "source": [
+ "# load_yaml\n",
+ "\n",
+ "Loads a YAML file.\n",
+ "\n",
+ "## Example"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev1.group_1\n",
+ "YAML data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev2.group_1\n",
+ "YAML data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev3.group_2\n",
+ "YAML data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev4.group_2\n",
+ "YAML data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev5.no_group\n",
+ "YAML data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n"
+ ]
+ }
+ ],
+ "source": [
+ "from nornir import InitNornir\n",
+ "from nornir_utils.plugins.tasks.data import load_yaml\n",
+ "\n",
+ "nr = InitNornir(\n",
+ " inventory={\n",
+ " \"plugin\": \"SimpleInventory\",\n",
+ " \"options\": {\"host_file\": \"data/hosts.yaml\", \"group_file\": \"data/groups.yaml\"},\n",
+ " }\n",
+ ")\n",
+ "\n",
+ "r = nr.run(task=load_yaml, file=\"data/ip_addresses.yaml\")\n",
+ "for host, m_result in r.items():\n",
+ " print()\n",
+ " print(\"-\" * 40)\n",
+ " print(f\"Host: {host}\")\n",
+ " print(f\"YAML data: {m_result.result}\")\n",
+ " print(\"-\" * 40)"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.8.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/docs/doctrees/nbsphinx/tutorials/processor_PrintResult.ipynb b/docs/doctrees/nbsphinx/tutorials/processor_PrintResult.ipynb
index f894080..a41e877 100644
--- a/docs/doctrees/nbsphinx/tutorials/processor_PrintResult.ipynb
+++ b/docs/doctrees/nbsphinx/tutorials/processor_PrintResult.ipynb
@@ -50,7 +50,7 @@
"\n",
"nr = InitNornir(\n",
" inventory={\n",
- " \"plugin\":\"SimpleInventory\",\n",
+ " \"plugin\":\"YAMLInventory\",\n",
" \"options\": {\n",
" \"host_file\": \"data/hosts.yaml\",\n",
" \"group_file\": \"data/groups.yaml\",\n",
diff --git a/docs/doctrees/tutorials/echo_data.doctree b/docs/doctrees/tutorials/echo_data.doctree
new file mode 100644
index 0000000..18f82f5
Binary files /dev/null and b/docs/doctrees/tutorials/echo_data.doctree differ
diff --git a/docs/doctrees/tutorials/function_print_result.doctree b/docs/doctrees/tutorials/function_print_result.doctree
index 75e667b..1c336e6 100644
Binary files a/docs/doctrees/tutorials/function_print_result.doctree and b/docs/doctrees/tutorials/function_print_result.doctree differ
diff --git a/docs/doctrees/tutorials/function_print_title.doctree b/docs/doctrees/tutorials/function_print_title.doctree
index 90640e0..0eb80db 100644
Binary files a/docs/doctrees/tutorials/function_print_title.doctree and b/docs/doctrees/tutorials/function_print_title.doctree differ
diff --git a/docs/doctrees/tutorials/index.doctree b/docs/doctrees/tutorials/index.doctree
index a0da716..3888fdc 100644
Binary files a/docs/doctrees/tutorials/index.doctree and b/docs/doctrees/tutorials/index.doctree differ
diff --git a/docs/doctrees/tutorials/inventory_SimpleInventory.doctree b/docs/doctrees/tutorials/inventory_YAMLInventory.doctree
similarity index 91%
rename from docs/doctrees/tutorials/inventory_SimpleInventory.doctree
rename to docs/doctrees/tutorials/inventory_YAMLInventory.doctree
index e5261a8..630f070 100644
Binary files a/docs/doctrees/tutorials/inventory_SimpleInventory.doctree and b/docs/doctrees/tutorials/inventory_YAMLInventory.doctree differ
diff --git a/docs/doctrees/tutorials/load_json.doctree b/docs/doctrees/tutorials/load_json.doctree
new file mode 100644
index 0000000..51e86b6
Binary files /dev/null and b/docs/doctrees/tutorials/load_json.doctree differ
diff --git a/docs/doctrees/tutorials/load_yaml.doctree b/docs/doctrees/tutorials/load_yaml.doctree
new file mode 100644
index 0000000..ec7db35
Binary files /dev/null and b/docs/doctrees/tutorials/load_yaml.doctree differ
diff --git a/docs/doctrees/tutorials/processor_PrintResult.doctree b/docs/doctrees/tutorials/processor_PrintResult.doctree
index ce40e5c..cab9f18 100644
Binary files a/docs/doctrees/tutorials/processor_PrintResult.doctree and b/docs/doctrees/tutorials/processor_PrintResult.doctree differ
diff --git a/docs/html/_sources/api/tasks.rst.txt b/docs/html/_sources/api/tasks.rst.txt
new file mode 100644
index 0000000..d0152ca
--- /dev/null
+++ b/docs/html/_sources/api/tasks.rst.txt
@@ -0,0 +1,6 @@
+tasks
+=====
+
+.. automodule:: nornir_utils.plugins.tasks.data
+ :members:
+ :undoc-members:
diff --git a/docs/html/_sources/tutorials/echo_data.ipynb.txt b/docs/html/_sources/tutorials/echo_data.ipynb.txt
new file mode 100644
index 0000000..0129dd7
--- /dev/null
+++ b/docs/html/_sources/tutorials/echo_data.ipynb.txt
@@ -0,0 +1,99 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": false
+ },
+ "source": [
+ "# echo_data\n",
+ "\n",
+ "echo_data is a data plugin that echoes the data passed into it. It is useful in grouped_tasks debugging.\n",
+ "\n",
+ "## Example"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\u001B[1m\u001B[36mgrouped_task********************************************************************\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[34m* dev1.group_1 ** changed : False **********************************************\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[32mvvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[32m---- dev1.group_1 ** changed : False ------------------------------------------- INFO\u001B[0m\n",
+ "\u001B[0m{'role': 'www'}\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[32m^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[34m* dev2.group_1 ** changed : False **********************************************\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[32mvvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[32m---- dev2.group_1 ** changed : False ------------------------------------------- INFO\u001B[0m\n",
+ "\u001B[0m{'role': 'db'}\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[32m^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[34m* dev3.group_2 ** changed : False **********************************************\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[32mvvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[32m---- dev3.group_2 ** changed : False ------------------------------------------- INFO\u001B[0m\n",
+ "\u001B[0m{'role': 'www'}\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[32m^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[34m* dev4.group_2 ** changed : False **********************************************\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[32mvvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[32m---- dev4.group_2 ** changed : False ------------------------------------------- INFO\u001B[0m\n",
+ "\u001B[0m{'role': 'db'}\u001B[0m\n",
+ "\u001B[0m\u001B[1m\u001B[32m^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\u001B[0m\n",
+ "\u001B[0m"
+ ]
+ }
+ ],
+ "source": [
+ "from nornir import InitNornir\n",
+ "from nornir.core.filter import F\n",
+ "from nornir_utils.plugins.tasks.data import echo_data\n",
+ "from nornir_utils.plugins.functions import print_result\n",
+ "\n",
+ "nr = InitNornir(\n",
+ " inventory={\n",
+ " \"plugin\": \"SimpleInventory\",\n",
+ " \"options\": {\"host_file\": \"data/hosts.yaml\", \"group_file\": \"data/groups.yaml\"},\n",
+ " }\n",
+ ")\n",
+ "nr = nr.filter(~F(name=\"dev5.no_group\"))\n",
+ "\n",
+ "\n",
+ "def grouped_task(task):\n",
+ " task.run(task=echo_data, name=task.host.name, role=task.host[\"role\"])\n",
+ "\n",
+ "\n",
+ "r = nr.run(task=grouped_task)\n",
+ "print_result(r)"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.8.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/docs/html/_sources/tutorials/function_print_result.ipynb.txt b/docs/html/_sources/tutorials/function_print_result.ipynb.txt
index 57cac67..e284ae5 100644
--- a/docs/html/_sources/tutorials/function_print_result.ipynb.txt
+++ b/docs/html/_sources/tutorials/function_print_result.ipynb.txt
@@ -22,7 +22,7 @@
"\n",
"nr = InitNornir(\n",
" inventory={\n",
- " \"plugin\":\"SimpleInventory\",\n",
+ " \"plugin\":\"YAMLInventory\",\n",
" \"options\": {\n",
" \"host_file\": \"data/hosts.yaml\",\n",
" \"group_file\": \"data/groups.yaml\",\n",
diff --git a/docs/html/tutorials/inventory_SimpleInventory.ipynb b/docs/html/_sources/tutorials/inventory_YAMLInventory.ipynb.txt
similarity index 97%
rename from docs/html/tutorials/inventory_SimpleInventory.ipynb
rename to docs/html/_sources/tutorials/inventory_YAMLInventory.ipynb.txt
index b5398ca..5a2e96c 100644
--- a/docs/html/tutorials/inventory_SimpleInventory.ipynb
+++ b/docs/html/_sources/tutorials/inventory_YAMLInventory.ipynb.txt
@@ -4,10 +4,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "# inventory: SimpleInventory\n",
+ "# inventory: YAMLInventory\n",
"\n",
"\n",
- "[SimpleInventory](../api/inventory.rst#nornir_utils.plugins.inventory.SimpleInventory) is an inventory plugin that builds the inventory from a few YAML files.\n",
+ "[YAMLInventory](../api/inventory.rst#nornir_utils.plugins.inventory.YAMLInventory) is an inventory plugin that builds the inventory from a few YAML files.\n",
"\n",
"## Data\n",
"\n",
@@ -203,7 +203,7 @@
"source": [
"## Example\n",
"\n",
- "Once you have the yaml files, using the plugin is very simple, you just need to specify the plugin you want to use is `SimpleInventory` and where to find the files:"
+ "Once you have the yaml files, using the plugin is very simple, you just need to specify the plugin you want to use is `YAMLInventory` and where to find the files:"
]
},
{
@@ -216,7 +216,7 @@
"\n",
"nr = InitNornir(\n",
" inventory={\n",
- " \"plugin\":\"SimpleInventory\",\n",
+ " \"plugin\":\"YAMLInventory\",\n",
" \"options\": {\n",
" \"host_file\": \"data/hosts.yaml\",\n",
" \"group_file\": \"data/groups.yaml\",\n",
diff --git a/docs/html/_sources/tutorials/load_json.ipynb.txt b/docs/html/_sources/tutorials/load_json.ipynb.txt
new file mode 100644
index 0000000..fadb9d6
--- /dev/null
+++ b/docs/html/_sources/tutorials/load_json.ipynb.txt
@@ -0,0 +1,99 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": false
+ },
+ "source": [
+ "# load_json\n",
+ "\n",
+ "Loads a JSON file.\n",
+ "\n",
+ "## Example"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev1.group_1\n",
+ "JSON data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev2.group_1\n",
+ "JSON data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev3.group_2\n",
+ "JSON data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev4.group_2\n",
+ "JSON data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev5.no_group\n",
+ "JSON data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n"
+ ]
+ }
+ ],
+ "source": [
+ "from nornir import InitNornir\n",
+ "from nornir_utils.plugins.tasks.data import load_json\n",
+ "\n",
+ "nr = InitNornir(\n",
+ " inventory={\n",
+ " \"plugin\": \"SimpleInventory\",\n",
+ " \"options\": {\"host_file\": \"data/hosts.yaml\", \"group_file\": \"data/groups.yaml\"},\n",
+ " }\n",
+ ")\n",
+ "\n",
+ "r = nr.run(task=load_json, file=\"data/ip_addresses.json\")\n",
+ "for host, m_result in r.items():\n",
+ " print()\n",
+ " print(\"-\" * 40)\n",
+ " print(f\"Host: {host}\")\n",
+ " print(f\"JSON data: {m_result.result}\")\n",
+ " print(\"-\" * 40)"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.8.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/docs/html/_sources/tutorials/load_yaml.ipynb.txt b/docs/html/_sources/tutorials/load_yaml.ipynb.txt
new file mode 100644
index 0000000..d213592
--- /dev/null
+++ b/docs/html/_sources/tutorials/load_yaml.ipynb.txt
@@ -0,0 +1,100 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": false
+ },
+ "source": [
+ "# load_yaml\n",
+ "\n",
+ "Loads a YAML file.\n",
+ "\n",
+ "## Example"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "pycharm": {
+ "name": "#%%\n"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "output_type": "stream",
+ "text": [
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev1.group_1\n",
+ "YAML data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev2.group_1\n",
+ "YAML data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev3.group_2\n",
+ "YAML data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev4.group_2\n",
+ "YAML data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n",
+ "\n",
+ "----------------------------------------\n",
+ "Host: dev5.no_group\n",
+ "YAML data: ['8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1']\n",
+ "----------------------------------------\n"
+ ]
+ }
+ ],
+ "source": [
+ "from nornir import InitNornir\n",
+ "from nornir_utils.plugins.tasks.data import load_yaml\n",
+ "\n",
+ "nr = InitNornir(\n",
+ " inventory={\n",
+ " \"plugin\": \"SimpleInventory\",\n",
+ " \"options\": {\"host_file\": \"data/hosts.yaml\", \"group_file\": \"data/groups.yaml\"},\n",
+ " }\n",
+ ")\n",
+ "\n",
+ "r = nr.run(task=load_yaml, file=\"data/ip_addresses.yaml\")\n",
+ "for host, m_result in r.items():\n",
+ " print()\n",
+ " print(\"-\" * 40)\n",
+ " print(f\"Host: {host}\")\n",
+ " print(f\"YAML data: {m_result.result}\")\n",
+ " print(\"-\" * 40)"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.8.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/docs/html/_sources/tutorials/processor_PrintResult.ipynb.txt b/docs/html/_sources/tutorials/processor_PrintResult.ipynb.txt
index f894080..a41e877 100644
--- a/docs/html/_sources/tutorials/processor_PrintResult.ipynb.txt
+++ b/docs/html/_sources/tutorials/processor_PrintResult.ipynb.txt
@@ -50,7 +50,7 @@
"\n",
"nr = InitNornir(\n",
" inventory={\n",
- " \"plugin\":\"SimpleInventory\",\n",
+ " \"plugin\":\"YAMLInventory\",\n",
" \"options\": {\n",
" \"host_file\": \"data/hosts.yaml\",\n",
" \"group_file\": \"data/groups.yaml\",\n",
diff --git a/docs/html/api/functions.html b/docs/html/api/functions.html
index cf0b153..137f43a 100644
--- a/docs/html/api/functions.html
+++ b/docs/html/api/functions.html
@@ -87,6 +87,7 @@
functions
inventory
processors
+tasks
Tutorials
diff --git a/docs/html/api/index.html b/docs/html/api/index.html
index cbec3d6..9dc9438 100644
--- a/docs/html/api/index.html
+++ b/docs/html/api/index.html
@@ -87,6 +87,7 @@
functions
inventory
processors
+tasks
Tutorials
@@ -186,6 +187,7 @@ API