Nornir(inventory: nornir.core.inventory.Inventory, config: nornir.core.configuration.Config = None, data: nornir.core.state.GlobalState = None, processors: Optional[nornir.core.processor.Processors] = None, runner: Optional[nornir.core.plugins.runners.RunnerPlugin] = None)¶
This is the main object to work with. It contains the inventory and it serves as task dispatcher.
shared data amongst different iterations of nornir
Whether if we are testing the changes or not
Return a dictionary representing the object.
Returns: A new object with same configuration as
selfbut filtered inventory.
run(task, raise_on_error=None, on_good=True, on_failed=False, name: Optional[str] = None, **kwargs)¶
Run task over all the hosts in the inventory.
- task (
callable) – function or callable that will be run against each device in the inventory
- raise_on_error (
bool) – Override raise_on_error behavior
- on_good (
bool) – Whether to run or not this task on hosts marked as good
- on_failed (
bool) – Whether to run or not this task on hosts marked as failed
- **kwargs – additional argument to pass to
taskwhen calling it
nornir.core.exceptions.NornirExecutionError– if at least a task fails and self.config.core.raise_on_error is set to
results of each execution
- task (
with_processors(processors: List[nornir.core.processor.Processor]) → nornir.core.__init__.Nornir¶
Given a list of Processor objects return a copy of the nornir object with the processors assigned to the copy. The orinal object is left unmodified.
with_runner(runner: nornir.core.plugins.runners.RunnerPlugin) → nornir.core.__init__.Nornir¶
Given a runner return a copy of the nornir object with the runner assigned to the copy. The orinal object is left unmodified.