mirror of https://github.com/ansible/ansible.git
Account for overlays when interacting with Jinja envs (#80705)
Instead of using Templar.environment in Templar.do_template for accessing/mutating the environment, myenv local variable should be used because it is the environment used for actual templating. It can either point to Templar.environment or newly created environment overlay. Fixes #80605pull/80723/head
parent
7eada15d1e
commit
8cd95a8e66
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- "Properly disable ``jinja2_native`` in the template module when jinja2 override is used in the template (https://github.com/ansible/ansible/issues/80605)"
|
@ -0,0 +1,15 @@
|
||||
- hosts: localhost
|
||||
gather_facts: false
|
||||
vars:
|
||||
output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
|
||||
tasks:
|
||||
- template:
|
||||
src: macro_override.j2
|
||||
dest: "{{ output_dir }}/macro_override.out"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "'foobar' not in data"
|
||||
- "'\"foo\" \"bar\"' in data"
|
||||
vars:
|
||||
data: "{{ lookup('file', '{{ output_dir }}/macro_override.out') }}"
|
@ -0,0 +1,7 @@
|
||||
#jinja2: variable_start_string:'<<',variable_end_string:'>>'
|
||||
Use a jinja2 override to trigger creating and using an environment overlay.
|
||||
|
||||
{% macro m() %}
|
||||
"foo" "bar"
|
||||
{% endmacro %}
|
||||
<< m() >>
|
Loading…
Reference in New Issue