1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Change conditional operation workflow.

Conflicts:

	lib/ansible/utils/__init__.py
This commit is contained in:
Michael DeHaan 2013-07-21 10:37:02 -04:00
parent 7f462a346a
commit 0756aa406a

View file

@ -162,11 +162,17 @@ def check_conditional(conditional, basedir, inject, fail_on_undefined=False):
# allow variable names # allow variable names
if conditional in inject: if conditional in inject:
conditional = inject[conditional] conditional = inject[conditional]
print "INJECTIFYING: %s" % inject
conditional = template.template(basedir, conditional, inject, fail_on_undefined=fail_on_undefined) conditional = template.template(basedir, conditional, inject, fail_on_undefined=fail_on_undefined)
# 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 %}"
return presented 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