echo_data

[1]:
from nornir.plugins.tasks.data import echo_data

print(echo_data.__doc__)
    Dummy task that echoes the data passed to it. Useful in grouped_tasks
    to debug data passed to tasks.

    Arguments:
        ``**kwargs``: Any <key,value> pair you want

    Returns:
        Result object with the following attributes set:
          * result (``dict``): ``**kwargs`` passed to the task

Example

[2]:
from nornir import InitNornir
from nornir.plugins.tasks.data import echo_data
from nornir.plugins.functions.text import print_result

nr = InitNornir(
    inventory={
        "options": {
            "host_file": "echo_data/inventory/hosts.yaml",
            "group_file": "echo_data/inventory/groups.yaml"
        }
    }
)

def grouped_task(task):
    task.run(task=echo_data,
             name=task.host.name,
             diet=task.host["diet"],
             famous_members=task.host["additional_data"]["famous_members"],
             more_data="whatever you want",
             even_complex={"a": 1, "b": 2, "c": "asd"})

r = nr.run(task=grouped_task)
print_result(r)
grouped_task********************************************************************
* bat ** changed : False *******************************************************
vvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
---- bat ** changed : False ---------------------------------------------------- INFO
{ 'diet': 'carnivore',
  'even_complex': {'a': 1, 'b': 2, 'c': 'asd'},
  'famous_members': ['batman', 'count chocula', 'nosferatu'],
  'more_data': 'whatever you want'}
^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* canary ** changed : False ****************************************************
vvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
---- canary ** changed : False ------------------------------------------------- INFO
{ 'diet': 'herbivore',
  'even_complex': {'a': 1, 'b': 2, 'c': 'asd'},
  'famous_members': ['tweetie'],
  'more_data': 'whatever you want'}
^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* cat ** changed : False *******************************************************
vvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
---- cat ** changed : False ---------------------------------------------------- INFO
{ 'diet': 'omnivore',
  'even_complex': {'a': 1, 'b': 2, 'c': 'asd'},
  'famous_members': ['garfield', 'felix', 'grumpy'],
  'more_data': 'whatever you want'}
^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* caterpillaer ** changed : False **********************************************
vvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
---- caterpillaer ** changed : False ------------------------------------------- INFO
{ 'diet': 'herbivore',
  'even_complex': {'a': 1, 'b': 2, 'c': 'asd'},
  'famous_members': ['Hookah-Smoking'],
  'more_data': 'whatever you want'}
^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* eagle ** changed : False *****************************************************
vvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
---- eagle ** changed : False -------------------------------------------------- INFO
{ 'diet': 'carnivore',
  'even_complex': {'a': 1, 'b': 2, 'c': 'asd'},
  'famous_members': ['thorondor', 'sam'],
  'more_data': 'whatever you want'}
^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* octopus ** changed : False ***************************************************
vvvv grouped_task ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv INFO
---- octopus ** changed : False ------------------------------------------------ INFO
{ 'diet': 'carnivore',
  'even_complex': {'a': 1, 'b': 2, 'c': 'asd'},
  'famous_members': ['sharktopus'],
  'more_data': 'whatever you want'}
^^^^ END grouped_task ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^