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

Add when_boolean

Fixes #1567.
This commit is contained in:
Daniel Hokka Zakrisson 2012-11-22 23:10:11 +01:00
parent ddef608c94
commit fd732f8d3b

View file

@ -228,6 +228,14 @@ class Task(object):
tcopy[i] = t
return " ".join(tcopy)
# when_boolean
elif tokens[0] in [ 'bool', 'boolean' ]:
tcopy = tokens[1:]
for (i, t) in enumerate(tcopy):
if t.find("$") != -1:
tcopy[i] = "(is_set('''%s''') and '''%s'''.lower() not in ('false', 'none', '0', ''))" % (t, t)
return " ".join(tcopy)
else:
raise errors.AnsibleError("invalid usage of when_ operator: %s" % expression)