Upgrading to nornir 3.x from 2.x

If you find some change not documented below don’t hesitate to open a PR or issue about it :)

Plugin Register

Introduced plugin register

Starting with nornir3 some plugins need to be registered. See plugins section for details.

Inventory

  1. Remove inventory deserializer

  2. Fixed mypy

  3. ParentGroups is simplified

  4. __init__ functions are more explicit in order to improve correctness

  5. Removed add_host and add_group

  6. Removed get_inventory_dict, get_defaults_dict, get_groups_dict, get_hosts_dict. Only dict remains

  7. Inventory plugins need to be registered

  8. Transform functions need to be registered

InitNornir

  1. Passing callables as inventory plugin and transform functions is no longer supported

  2. configure_logging has been removed (it used to indicate it was to be deprecated)

Configuration

  1. Order of resolution for parameters is now InitNornir > config > environment

  2. jinja2 can no longer be configured using the configuration

  3. num_workers is no longer a core option

  4. logging.file is now logging.log_file

  5. new runner section introduced

num_workers

Nornir used to accept num_workers under the core configuration section. This used to instruct whether to use threads or not and how many. This has now changed with the introduction of runners. Now if you want to avoid using threads you would instruct nornir to use the SerialRunner like this:

  1. #config.yaml
  2. runners:
  3. plugin: serial

To tweak the number of threads:

  1. #config.yaml
  2. runners:
  3. plugin: threaded
  4. options:
  5. num_workers: 100

For this same reason NORNIR_CORE_NUM_WORKERS doesn’t work anymore. You should be able to do NORNIR_RUNNER_OPTIONS='{"num_workers": 100}' instead.