|
|
@ -99,10 +99,10 @@ class Task(object):
|
|
|
|
|
|
|
|
|
|
|
|
# delegate_to can use variables
|
|
|
|
# delegate_to can use variables
|
|
|
|
if not (self.delegate_to is None):
|
|
|
|
if not (self.delegate_to is None):
|
|
|
|
self.delegate_to = utils.template(None, self.delegate_to, self.module_vars)
|
|
|
|
self.delegate_to = utils.template(None, self.delegate_to, self.module_vars)
|
|
|
|
# delegate_to: localhost should use local transport
|
|
|
|
# delegate_to: localhost should use local transport
|
|
|
|
if self.delegate_to in ['127.0.0.1', 'localhost']:
|
|
|
|
if self.delegate_to in ['127.0.0.1', 'localhost']:
|
|
|
|
self.transport = 'local'
|
|
|
|
self.transport = 'local'
|
|
|
|
|
|
|
|
|
|
|
|
# notified by is used by Playbook code to flag which hosts
|
|
|
|
# notified by is used by Playbook code to flag which hosts
|
|
|
|
# need to run a notifier
|
|
|
|
# need to run a notifier
|
|
|
@ -195,37 +195,37 @@ class Task(object):
|
|
|
|
# when: str $x != $y
|
|
|
|
# when: str $x != $y
|
|
|
|
|
|
|
|
|
|
|
|
if type(expression) not in [ str, unicode ]:
|
|
|
|
if type(expression) not in [ str, unicode ]:
|
|
|
|
raise errors.AnsibleError("invalid usage of when_ operator: %s" % expression)
|
|
|
|
raise errors.AnsibleError("invalid usage of when_ operator: %s" % expression)
|
|
|
|
tokens = expression.split()
|
|
|
|
tokens = expression.split()
|
|
|
|
if len(tokens) < 2:
|
|
|
|
if len(tokens) < 2:
|
|
|
|
raise errors.AnsibleError("invalid usage of when_ operator: %s" % expression)
|
|
|
|
raise errors.AnsibleError("invalid usage of when_ operator: %s" % expression)
|
|
|
|
|
|
|
|
|
|
|
|
# when_set / when_unset
|
|
|
|
# when_set / when_unset
|
|
|
|
if tokens[0] in [ 'set', 'unset' ]:
|
|
|
|
if tokens[0] in [ 'set', 'unset' ]:
|
|
|
|
if len(tokens) != 2:
|
|
|
|
if len(tokens) != 2:
|
|
|
|
raise errors.AnsibleError("usage: when: <set|unset> <$variableName>")
|
|
|
|
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
|
|
|
|
# when_integer / when_float / when_string
|
|
|
|
elif tokens[0] in [ 'integer', 'float', 'string' ]:
|
|
|
|
elif tokens[0] in [ 'integer', 'float', 'string' ]:
|
|
|
|
cast = None
|
|
|
|
cast = None
|
|
|
|
if tokens[0] == 'integer':
|
|
|
|
if tokens[0] == 'integer':
|
|
|
|
cast = 'int'
|
|
|
|
cast = 'int'
|
|
|
|
elif tokens[0] == 'string':
|
|
|
|
elif tokens[0] == 'string':
|
|
|
|
cast = 'str'
|
|
|
|
cast = 'str'
|
|
|
|
elif tokens[0] == 'float':
|
|
|
|
elif tokens[0] == 'float':
|
|
|
|
cast = 'float'
|
|
|
|
cast = 'float'
|
|
|
|
tcopy = tokens[1:]
|
|
|
|
tcopy = tokens[1:]
|
|
|
|
for (i,t) in enumerate(tokens[1:]):
|
|
|
|
for (i,t) in enumerate(tokens[1:]):
|
|
|
|
if t.find("$") != -1:
|
|
|
|
if t.find("$") != -1:
|
|
|
|
# final variable substitution will happen in Runner code
|
|
|
|
# final variable substitution will happen in Runner code
|
|
|
|
tcopy[i] = "%s('%s')" % (cast, t)
|
|
|
|
tcopy[i] = "%s('%s')" % (cast, t)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
tcopy[i] = t
|
|
|
|
tcopy[i] = t
|
|
|
|
return " ".join(tcopy)
|
|
|
|
return " ".join(tcopy)
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise errors.AnsibleError("invalid usage of when_ operator: %s" % expression)
|
|
|
|
raise errors.AnsibleError("invalid usage of when_ operator: %s" % expression)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|