From a5d84212b1cb2d77d56ecab968925bf340ae9fc1 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Tue, 28 Nov 2023 12:19:52 -0600 Subject: [PATCH] comments --- lib/ansible/template/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/template/__init__.py b/lib/ansible/template/__init__.py index 9b6c4113521..63ce783140b 100644 --- a/lib/ansible/template/__init__.py +++ b/lib/ansible/template/__init__.py @@ -592,10 +592,15 @@ class AnsibleEnvironment(NativeEnvironment): if not C.JINJA2_BYTECODE_CACHE: return super().compile(source, name=name, filename=filename, raw=raw, defer_init=defer_init) # type: ignore[call-overload] + # Environment._parse parsed = Parser(self, source, name, filename).parse() + + # This wrapper ensures that all templates are not considered literal/constant eval_ctx = nodes.ScopedEvalContextModifier(lineno=-1) eval_ctx.options = [nodes.Keyword('volatile', nodes.Const(True))] eval_ctx.body = parsed.body + + # Environment._generate generated = generate( nodes.Template([eval_ctx], lineno=-1), self, @@ -604,6 +609,7 @@ class AnsibleEnvironment(NativeEnvironment): defer_init=False, optimized=self.optimized, ) + return compile(generated, filename or '