mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
stringify conditional before handing it to Jinja2 for evaluation.
This should fix simple conditionals like:
when: ansible_selinux
While here add tests for ansible.utils.check_conditional() in
"jinja2_compare mode".
This commit is contained in:
@@ -164,7 +164,7 @@ def check_conditional(conditional, basedir, inject, fail_on_undefined=False):
|
||||
conditional = inject[conditional]
|
||||
conditional = template.template(basedir, conditional, inject, fail_on_undefined=fail_on_undefined)
|
||||
# a Jinja2 evaluation that results in something Python can eval!
|
||||
presented = "{% if " + conditional + " %} True {% else %} False {% endif %}"
|
||||
presented = "{%% if %s %%} True {%% else %%} False {%% endif %%}" % conditional
|
||||
conditional = template.template(basedir, presented, inject)
|
||||
val = conditional.lstrip().rstrip()
|
||||
if val == "True":
|
||||
|
||||
Reference in New Issue
Block a user