mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-22 20:13:59 -07:00
Don't restrict local jinja2 variables to those that start with l_
Per a change in jinja2 2.9, local variables no longer are prefixed with l_, so this updates AnsibleJ2Vars to pull in all locals (while excluding some) regardless of name. Fixes #20063 (cherry picked from commit 4d49b317929b86e1fc1b0cbace825ff73b372dc7)
This commit is contained in:
parent
fc04164505
commit
188c3c608a
6 changed files with 40 additions and 6 deletions
|
@ -229,3 +229,17 @@
|
|||
that:
|
||||
- "'templated_var_loaded' in lookup('file', '{{output_dir | expanduser }}/short.templated')"
|
||||
- "template_result|changed"
|
||||
|
||||
# Create a template using a child template, to ensure that variables
|
||||
# are passed properly from the parent to subtemplate context (issue #20063)
|
||||
|
||||
- name: test parent and subtemplate creation of context
|
||||
template: src=parent.j2 dest={{output_dir}}/parent_and_subtemplate.templated
|
||||
register: template_result
|
||||
|
||||
- stat: path={{output_dir}}/parent_and_subtemplate.templated
|
||||
|
||||
- name: verify that the parent and subtemplate creation worked
|
||||
assert:
|
||||
that:
|
||||
- "template_result|changed"
|
||||
|
|
3
test/integration/targets/template/templates/parent.j2
Normal file
3
test/integration/targets/template/templates/parent.j2
Normal file
|
@ -0,0 +1,3 @@
|
|||
{% for parent_item in parent_vars %}
|
||||
{% include "subtemplate.j2" %}
|
||||
{% endfor %}
|
|
@ -0,0 +1,2 @@
|
|||
{{ parent_item }}
|
||||
|
|
@ -13,3 +13,8 @@ templated_dict:
|
|||
null_type: "{{ null_type }}"
|
||||
bool: "{{ bool_var }}"
|
||||
multi_part: "{{ part_1 }}{{ part_2 }}"
|
||||
|
||||
parent_vars:
|
||||
- foo
|
||||
- bar
|
||||
- bam
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue