mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07:00
Change conditional operation workflow.
This commit is contained in:
parent
1acd9b6325
commit
3f1f0e7bc2
1 changed files with 8 additions and 0 deletions
|
@ -165,6 +165,14 @@ def check_conditional(conditional, basedir, inject):
|
||||||
conditional = template.template(basedir, conditional, inject)
|
conditional = template.template(basedir, conditional, inject)
|
||||||
# a Jinja2 evaluation that results in something Python can eval!
|
# a Jinja2 evaluation that results in something Python can eval!
|
||||||
presented = "{% if " + conditional + " %} True {% else %} False {% endif %}"
|
presented = "{% if " + conditional + " %} True {% else %} False {% endif %}"
|
||||||
|
conditional = template.template(basedir, presented, inject)
|
||||||
|
val = conditional.lstrip().rstrip()
|
||||||
|
if val == "True":
|
||||||
|
return True
|
||||||
|
elif val == "False":
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
raise errors.AnsibleError("unable to evaluate conditional: %s" % conditional)
|
||||||
|
|
||||||
if not isinstance(conditional, basestring):
|
if not isinstance(conditional, basestring):
|
||||||
return conditional
|
return conditional
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue