From b518b9e62153124bc495d0c90a411a5f5fa92a02 Mon Sep 17 00:00:00 2001 From: Eric Hansen Date: Mon, 17 Jul 2023 11:45:28 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Add=20support=20for=20passi?= =?UTF-8?q?ng=20in=20custom=20jinja2=20environment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/nautobot/nautobot-plugin-golden-config/issues/525 --- nornir_nautobot/plugins/tasks/dispatcher/default.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nornir_nautobot/plugins/tasks/dispatcher/default.py b/nornir_nautobot/plugins/tasks/dispatcher/default.py index 46c2941..2310200 100644 --- a/nornir_nautobot/plugins/tasks/dispatcher/default.py +++ b/nornir_nautobot/plugins/tasks/dispatcher/default.py @@ -162,6 +162,7 @@ def generate_config( jinja_root_path: str, output_file_location: str, jinja_filters: Optional[dict] = None, + jinja_env: Optional[jinja2.Environment] = None, ) -> Result: """A small wrapper around template_file Nornir task. @@ -172,6 +173,7 @@ def generate_config( jinja_template (str): The file location of the actual Jinja template. jinja_root_path (str): The file folder where the file will be saved to. jinja_filters (dict): The filters which will be added to the jinja2 environment. + jinja_env (jinja2.Environment): The jinja2 environment to use. If not provided, nornir will create one. output_file_location (str): The filename where the file will be saved to. Returns: @@ -184,6 +186,7 @@ def generate_config( template=jinja_template, path=jinja_root_path, jinja_filters=jinja_filters, + jinja_env=jinja_env, )[0].result except NornirSubTaskError as exc: if isinstance(exc.result.exception, jinja2.exceptions.UndefinedError): # pylint: disable=no-else-raise