Configuration

The configuration is comprised of a set of sections and parameters for those sections. You can set the configuration programmatically using nornir by passing a dictionary of options for each section, by using a YAML file, by setting the corresponding environment variables or by a combination of the three. The order of preference from less to more preferred is “configuration file” -> “env variable” -> “code”.

An example using InitNornir would be:

nr = InitNornir(
    core={"num_workers": 20},
    logging={"file": "mylogs", "level": "debug"}
)

A similar example using a yaml file:

---
core:
    num_workers: 20
inventory:
    plugin: nornir.plugins.inventory.simple.SimpleInventory
    options:
        host_file: "advanced_filtering/inventory/hosts.yaml"
        group_file: "advanced_filtering/inventory/groups.yaml"

Next, you can find each section and their corresponding options.

core

num_workers

Description Number of Nornir worker threads that are run at the same time by default
Type integer
Default 20
Required False
Environment Variable NORNIR_CORE_NUM_WORKERS

raise_on_error

Description If set to True, (nornir.core.Nornir.run) method of will raise exception nornir.core.exceptions.NornirExecutionError if at least a host failed
Type boolean
Default  
Required False
Environment Variable NORNIR_CORE_RAISE_ON_ERROR

inventory

plugin

Description Import path to inventory plugin
Type string
Default nornir.plugins.inventory.simple.SimpleInventory
Required False
Environment Variable NORNIR_INVENTORY_PLUGIN

options

Description kwargs to pass to the inventory plugin
Type object
Default  
Required False
Environment Variable NORNIR_INVENTORY_OPTIONS

transform_function

Description Path to transform function. The transform_function you provide will run against each host in the inventory
Type string
Default  
Required False
Environment Variable NORNIR_INVENTORY_TRANSFORM_FUNCTION

ssh

config_file

Description Path to ssh configuration file
Type string
Default ~/.ssh/config
Required False
Environment Variable NORNIR_SSH_CONFIG_FILE

logging

level

Description Logging level
Type string
Default debug
Required False
Environment Variable NORNIR_LOGGING_LEVEL

file

Description  
Type string
Default nornir.log
Required False
Environment Variable NORNIR_LOGGING_FILE

format

Description Logging format
Type string
Default %(asctime)s - %(name)12s - %(levelname)8s - %(funcName)10s() - %(message)s
Required False
Environment Variable NORNIR_LOGGING_FORMAT

to_console

Description Whether to log to console or not
Type boolean
Default  
Required False
Environment Variable NORNIR_LOGGING_TO_CONSOLE

loggers

Description Loggers to configure
Type array
Default ['nornir']
Required False
Environment Variable NORNIR_LOGGING_LOGGERS

jinja2

filters

Description Path to callable returning jinja filters to be used
Type string
Default  
Required False
Environment Variable NORNIR_JINJA2_FILTERS

user_defined

You can set any <k, v> pair you want here and you will have it available under your configuration object, i.e. nr.config.user_defined.my_app_option.