summaryrefslogtreecommitdiff
path: root/test/integration/targets/template/templates/72615.j2
diff options
context:
space:
mode:
authorMartin Krizek <martin.krizek@gmail.com>2021-02-05 19:43:16 +0100
committerGitHub <noreply@github.com>2021-02-05 12:43:16 -0600
commit65fdc41fb180fca8adb552eed1ae24736858c419 (patch)
tree6f5fddeef76a76beac14d15a68c20f8516562b75 /test/integration/targets/template/templates/72615.j2
parent8e5aab4d76896b4dcf735a626c281ddcb7b2d211 (diff)
downloadansible-65fdc41fb180fca8adb552eed1ae24736858c419.tar.gz
Local vars should have highest precedence in AnsibleJ2Vars (#72830) (#73369)
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 'test/integration/targets/template/templates/72615.j2')
-rw-r--r--test/integration/targets/template/templates/72615.j24
1 files changed, 4 insertions, 0 deletions
diff --git a/test/integration/targets/template/templates/72615.j2 b/test/integration/targets/template/templates/72615.j2
new file mode 100644
index 0000000000..b79f88e26d
--- /dev/null
+++ b/test/integration/targets/template/templates/72615.j2
@@ -0,0 +1,4 @@
+{% set foo = "template-level-foo" %}
+{% set bar = "template-level-bar" %}
+{% from '72615-macro.j2' import print_context_vars with context %}
+{{ print_context_vars(bar) }}