From cf548baeabf25086cf42b1f335a6ebd32da4504b Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 29 Sep 2014 18:06:48 -0400 Subject: [PATCH] Fix missing strip() in a1809a371a7d0f4dc13616ae25b9312e3cecbe8e --- lib/ansible/playbook/task.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index 5e38f63cc99..db10f7c494d 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -84,12 +84,13 @@ class Task(object): # code to allow "with_glob" and to reference a lookup plugin named glob elif x.startswith("with_"): - # Only a variable, no logic - if (isinstance(ds[x], basestring) and - ds[x].startswith('{{') and - ds[x].find('}}') == len(ds[x]) - 2 and - find ('|') == -1): - utils.warning("It is unnecessary to use '{{' in loops, leave variables in loop expressions bare.") + if isinstance(ds[x], basestring): + param = ds[x].strip() + # Only a variable, no logic + if (param.startswith('{{') and + param.find('}}') == len(ds[x]) - 2 and + param.find('|') == -1): + utils.warning("It is unnecessary to use '{{' in loops, leave variables in loop expressions bare.") plugin_name = x.replace("with_","") if plugin_name in utils.plugins.lookup_loader: @@ -100,12 +101,13 @@ class Task(object): raise errors.AnsibleError("cannot find lookup plugin named %s for usage in with_%s" % (plugin_name, plugin_name)) elif x in [ 'changed_when', 'failed_when', 'when']: - # Only a variable, no logic - if (isinstance(ds[x], basestring) and - ds[x].startswith('{{') and - ds[x].find('}}') == len(ds[x]) - 2 and - find ('|') == -1): - utils.warning("It is unnecessary to use '{{' in conditionals, leave variables in loop expressions bare.") + if isinstance(ds[x], basestring): + param = ds[x].strip() + # Only a variable, no logic + if (param.startswith('{{') and + param.find('}}') == len(ds[x]) - 2 and + param.find('|') == -1): + utils.warning("It is unnecessary to use '{{' in conditionals, leave variables in loop expressions bare.") elif x.startswith("when_"): utils.deprecated("The 'when_' conditional has been removed. Switch to using the regular unified 'when' statements as described on docs.ansible.com.","1.5", removed=True)