Last active
August 18, 2021 23:28
-
-
Save ktbyers/bdba984447636d5ac4e3d93011a861ad to your computer and use it in GitHub Desktop.
Use Ansible Jinja2 Filters in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jinja2.environment import Environment | |
from jinja2 import FileSystemLoader, StrictUndefined | |
from ansible_collections.ansible.netcommon.plugins.filter.ipaddr import ipmath | |
from ansible_collections.ansible.netcommon.plugins.filter.ipaddr import ipaddr | |
env = Environment(undefined=StrictUndefined) | |
env.loader = FileSystemLoader(['.', './templates/']) | |
env.filters["ipmath"] = ipmath | |
env.filters["ipaddr"] = ipaddr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment