Custom Jinja2 Filter "ipaddr"

Hello everyone

I’d like to have the some functionality in Nornir that the ‘ipaddr’ filter in Ansible provides. I naively downloaded the file from the Ansible Github Repo and tried to import that. I actually have no clue how to do that and the documentation is not really helping me… I don’t know if I dind’t find it or if it’s just not there.

I added this to my config.yaml:

  filters: "filters"

“filters” is just the folder where I put the Python file.

Now it’s giving me this:

Failed to import 'filters'
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/nornir/core/deserializer/", line 216, in _resolve_import_from_string
    module_name, obj_name = import_path.rsplit(".", 1)
ValueError: not enough values to unpack (expected 2, got 1)

It’s clear to me that I have to put “something.something” in the config.yaml. There’s also another question on here regarding this (more or less).
But I’m just lost at how to do that…

Is there a better way to do just that? My main point right now is that I want to write “” into my YAML files and to the handling in the Jinja templates. For example converting to “” and “”.

Thanks a lot in advance!

While we’re here:
What about using “hostvars” in a template? I assume this is also an Ansible thing? Thinking of something like neighbor {{ n.ip }} remote-as {{ hostvars[].bgp_as }}