From c7e198b907e2b3842270252e6fc94e32388e18e3 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Thu, 7 Apr 2022 16:52:12 +0200 Subject: [PATCH] Ensure correct environment_class is set on Template (#77485) --- .../fragments/templar-correct-environment_class-template.yml | 2 ++ lib/ansible/template/__init__.py | 1 + 2 files changed, 3 insertions(+) create mode 100644 changelogs/fragments/templar-correct-environment_class-template.yml diff --git a/changelogs/fragments/templar-correct-environment_class-template.yml b/changelogs/fragments/templar-correct-environment_class-template.yml new file mode 100644 index 00000000000..950d1bd9693 --- /dev/null +++ b/changelogs/fragments/templar-correct-environment_class-template.yml @@ -0,0 +1,2 @@ +bugfixes: + - Ensure the correct ``environment_class`` is set on ``AnsibleJ2Template`` diff --git a/lib/ansible/template/__init__.py b/lib/ansible/template/__init__.py index dbc15063e4e..e605a7f6e9c 100644 --- a/lib/ansible/template/__init__.py +++ b/lib/ansible/template/__init__.py @@ -674,6 +674,7 @@ class Templar: extensions=self._get_extensions(), loader=FileSystemLoader(loader.get_basedir() if loader else '.'), ) + self.environment.template_class.environment_class = environment_class # jinja2 global is inconsistent across versions, this normalizes them self.environment.globals['dict'] = dict