mirror of https://github.com/ansible/ansible.git
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 #80605
(cherry picked from commit 8cd95a8e66)
pull/81000/head
parent
cc0eaad410
commit
01000c622f
@ -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