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

Merge pull request #1608 from dhozac/when_set-non-string

Try to ensure the entire value is quoted
This commit is contained in:
Michael DeHaan 2012-11-12 17:45:47 -08:00
commit e3f7f86ac4

View file

@ -208,7 +208,7 @@ class Task(object):
if tokens[0] in [ 'set', 'unset' ]:
if len(tokens) != 2:
raise errors.AnsibleError("usage: when: <set|unset> <$variableName>")
return "is_%s('%s')" % (tokens[0], tokens[1])
return "is_%s('''%s''')" % (tokens[0], tokens[1])
# when_integer / when_float / when_string
elif tokens[0] in [ 'integer', 'float', 'string' ]:
@ -223,7 +223,7 @@ class Task(object):
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)
tcopy[i] = "%s('''%s''')" % (cast, t)
else:
tcopy[i] = t
return " ".join(tcopy)