mirror of https://github.com/ansible/ansible.git
In the classic Jinja2's Environment str() is called on the return value of the
finalize method to potentially trigger the undefined error. That is not
the case in NativeEnvironment where string conversion of the return value is
not desired. We workaround that by checking for Undefined in all of our concat
functions. It seems simpler to do it earlier in the finalize method(s) instead.
As a side-effect it fixes an undefined variable detection in imported templates.
Fixes #78156
ci_complete
(cherry picked from commit 17d52c8d64)
pull/78229/head
parent
d4cd1853b0
commit
6468bb0cb6
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- Move undefined check from concat to finalize (https://github.com/ansible/ansible/issues/78156)
|
||||
@ -0,0 +1 @@
|
||||
{{ undefined_variable }}
|
||||
@ -0,0 +1 @@
|
||||
{% import 'undefined_in_import-import.j2' as t %}
|
||||
@ -0,0 +1,11 @@
|
||||
- hosts: localhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- debug:
|
||||
msg: "{{ lookup('template', 'undefined_in_import.j2') }}"
|
||||
ignore_errors: true
|
||||
register: res
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "\"'undefined_variable' is undefined\" in res.msg"
|
||||
Loading…
Reference in New Issue