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 = k.replace("with_","")
if plugin_name in utils.plugins.lookup_loader:
results['_lookup_plugin'] = plugin_name
results['_lookup_terms'] = v
else:
raise errors.AnsibleError("cannot find lookup plugin named %s for usage in with_%s" % (plugin_name, plugin_name))
return results
def _load_legacy_when(self, ds, k, v):
'''yellaboutoldwhensyntaxbeingusedstill'''
# 'action' and 'local_action' are mutually-exclusive options
if'action'indsand'local_action'inds:
raiseAnsibleError("the 'action' and 'local_action' attributes can not be used together")
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)
utils.warning("It is unnecessary to use '{{' in loops, leave variables in loop expressions bare.")
plugin_name=k.replace("with_","")
ifplugin_nameinutils.plugins.lookup_loader:
self._lookup_plugin=plugin_name
self._lookup_terms=v
else:
raiseerrors.AnsibleError("cannot find lookup plugin named %s for usage in with_%s"%(plugin_name,plugin_name))
elifk.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)
ifself._when:
raiseerrors.AnsibleError("multiple when_* statements specified in task %s"%(ds.get('name',ds.get('action'))))
when_name=k.replace("when_","")
self._when="%s %s"%(when_name,v)
elifkin('changed_when','failed_when','when'):
# these are conditional objects, so we push the new conditional value
# into the object so that it can be evaluated later
getattr(self,'_%s'%k).push(v)
elifk=='tags':
# all taggable datastructures in Ansible (tasks, roles, etc.) are
# based on the Base() class, which includes the _tags attribute
# (which is a Tag() class)
tags=v
ifisinstance(v,basestring):
tags=v.split(',')
self._tags.push(tags)
elifknotinself.VALID_KEYS:
raiseAnsibleError("%s is not a legal parameter in an Ansible task or handler"%k)
else:
setattr(self,'_%s'%k,v)
# if args were specified along with parameters, merge them now