From a05361f51500c5a9f227f87f1ea91a45870602ce Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Thu, 11 Apr 2013 17:19:53 -0400 Subject: [PATCH] This is a fix on top of the 'airplane variable upgrade' commits that fixes legacy when_string so it evaluates correctly in the new eval construct. --- lib/ansible/runner/__init__.py | 1 - lib/ansible/utils/__init__.py | 16 +++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index c46753bc0e9..c6dbd998af9 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -66,7 +66,6 @@ def _executor_hook(job_queue, result_queue): return_data = multiprocessing_runner._executor(host) result_queue.put(return_data) - # print "FLAGS=%s" % return_data.flags if 'LEGACY_TEMPLATE_WARNING' in return_data.flags: # pass data back up across the multiprocessing fork boundary template.Flags.LEGACY_TEMPLATE_WARNING = True diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 68b384c6be9..762217c9fe7 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -601,12 +601,18 @@ def compile_when_to_only_if(expression): cast = 'float' tcopy = tokens[1:] for (i,t) in enumerate(tokens[1:]): - if t.find("$") != -1: - # final variable substitution will happen in Runner code - tcopy[i] = "%s('''%s''')" % (cast, t) + #if re.search(t, r"^\w"): + # bare word will turn into Jinja2 so all the above + # casting is really not needed + #tcopy[i] = "%s('''%s''')" % (cast, t) + t2 = t.strip() + if (t2[0].isalpha() or t2[0] == '$') and cast == 'str': + tcopy[i] = "'%s'" % (t) else: - tcopy[i] = t - return " ".join(tcopy) + tcopy[i] = t + result = " ".join(tcopy) + return result + # when_boolean elif tokens[0] in [ 'bool', 'boolean' ]: