Skip to content

InfrastructureAsCode-ch/nornir_rich

Repository files navigation

nornir_rich

Install

pip install nornir-rich

Usage

Features

  • Print functions
    • print_result
    • print_failed_hosts
    • print_inventory
  • Processors
    • progressbar

Print example

from nornir_rich.functions import print_result

results = nr.run(
    task=hello_world
)

print_result(results)
print_result(results, vars=["diff", "result", "name", "exception", "severity_level"])

Progress bar example

from time import sleep
from nornir_rich.progress_bar import RichProgressBar


def random_sleep(task: Task) -> Result:
    delay = randrange(10)
    sleep(delay)
    return Result(host=task.host, result=f"{delay} seconds delay")


nr_with_processors = nr.with_processors([RichProgressBar()])
result = nr_with_processors.run(task=random_sleep)

Images

Print Inventory

Print inventory

Print Result

Print Result

Progress Bar

Progress Bar

More examples