diff options
author | Martin Krizek <martin.krizek@gmail.com> | 2021-02-07 08:30:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-07 01:30:47 -0600 |
commit | 2c8c02c8168e938835844066570792fb59aad277 (patch) | |
tree | 68b7cc686876c382d84010f6d55d1f7f32738e28 /changelogs/fragments/72615-jinja-import-context-fix.yml | |
parent | e41d1f0a3fd6c466192e7e24accd3d1c6501111b (diff) | |
download | ansible-2c8c02c8168e938835844066570792fb59aad277.tar.gz |
Local vars should have highest precedence in AnsibleJ2Vars (#72830) (#73370)
Ability to add local variables into AnsibleJ2Vars was added in
18a9eff11f0a6e51b17405ce596bd9ff7e676320 to fix #6653. Local variables
are added using ``AnsibleJ2Vars.add_locals()`` method when creating a
new context - typically when including/importing a template with
context. For that use case local template variables created using
``set`` should override variables from higher contexts - either from the
play or any parent template, or both; Jinja behaves the same way.
Also removes AnsibleJ2Vars.extras instance variable which is not used.
Also adds missing test for #6653.
Fixes #72262
Fixes #72615
ci_complete
(cherry picked from commit a2af8432f36ec8cc5368a747f1211d2b9ba01f2e)
Diffstat (limited to 'changelogs/fragments/72615-jinja-import-context-fix.yml')
-rw-r--r-- | changelogs/fragments/72615-jinja-import-context-fix.yml | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/changelogs/fragments/72615-jinja-import-context-fix.yml b/changelogs/fragments/72615-jinja-import-context-fix.yml new file mode 100644 index 0000000000..0f4ff43141 --- /dev/null +++ b/changelogs/fragments/72615-jinja-import-context-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - Fix incorrect variable scoping when using ``import with context`` in Jinja2 templates. (https://github.com/ansible/ansible/issues/72615) |