From 0756aa406a24539e565c748dc9eebbd1c60abb46 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Sun, 21 Jul 2013 10:37:02 -0400 Subject: [PATCH] Change conditional operation workflow. Conflicts: lib/ansible/utils/__init__.py --- lib/ansible/utils/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 70f16ae337..a92c82caeb 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -162,11 +162,17 @@ def check_conditional(conditional, basedir, inject, fail_on_undefined=False): # allow variable names if conditional in inject: conditional = inject[conditional] - print "INJECTIFYING: %s" % inject 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 %}" - 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): return conditional