echo_data

echo_data is a data plugin that echoes the data passed into it. It is useful in grouped_tasks debugging.

Example

[7]:
from nornir import InitNornir
from nornir.core.filter import F
from nornir_utils.plugins.tasks.data import echo_data
from nornir_utils.plugins.functions import print_result

nr = InitNornir(
    inventory={
        "plugin": "SimpleInventory",
        "options": {"host_file": "data/hosts.yaml", "group_file": "data/groups.yaml"},
    }
)
nr = nr.filter(~F(name="dev5.no_group"))


def grouped_task(task):
    task.run(task=echo_data, name=task.host.name, role=task.host["role"])


r = nr.run(task=grouped_task)
print_result(r)
grouped_task********************************************************************
* dev1.group_1 ** changed : False **********************************************
vvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
---- dev1.group_1 ** changed : False ------------------------------------------- INFO
{'role': 'www'}
^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* dev2.group_1 ** changed : False **********************************************
vvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
---- dev2.group_1 ** changed : False ------------------------------------------- INFO
{'role': 'db'}
^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* dev3.group_2 ** changed : False **********************************************
vvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
---- dev3.group_2 ** changed : False ------------------------------------------- INFO
{'role': 'www'}
^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* dev4.group_2 ** changed : False **********************************************
vvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
---- dev4.group_2 ** changed : False ------------------------------------------- INFO
{'role': 'db'}
^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^