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