Also removing cruft code from earlier iteration on task.py and fixing
a bug where 'shell' was not removed from the task ds after munge()
cleaned things up
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:
results['_lookup_plugin']=plugin_name
results['_lookup_terms']=v
else:
raiseerrors.AnsibleError("cannot find lookup plugin named %s for usage in with_%s"%(plugin_name,plugin_name))
returnresults
def_load_legacy_when(self,ds,k,v):
''' yell about old when syntax being used still '''
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_","")
returndict(_when="%s%s"%(when_name,v))
def_load_when(self,ds,k,v):
''' validate/transmogrify/assign a conditional '''
conditionals=self._when.copy()
conditionals.push(v)
returndict(_when=conditionals)
def_load_changed_when(self,ds,k,v):
''' validate/transmogrify/assign a changed_when conditional '''
conditionals=self._changed_when.copy()
conditionals.push(v)
returndict(_changed_when=conditionals)
def_load_failed_when(self,ds,k,v):
''' validate/transmogrify/assign a failed_when conditional '''
conditionals=self._failed_when.copy()
conditionals.push(v)
returndict(_failed_when=conditionals)
# FIXME: move to BaseObject
def_load_tags(self,ds,k,v):
''' validate/transmogrify/assign any tags '''
new_tags=self.tags.copy()
tags=v
ifisinstance(v,basestring):
tags=v.split(',')
new_tags.push(v)
returndict(_tags=v)
def_load_invalid_key(self,ds,k,v):
''' handle any key we do not recognize '''
raiseAnsibleError("%s is not a legal parameter in an Ansible task or handler"%k)
def_load_other_valid_key(self,ds,k,v):
''' handle any other attribute we DO recognize '''
results=dict()
k="_%s"%k
results[k]=v
returnresults
def_loader_for_key(self,k):
''' based on the name of a datastructure element, find the code to handle it '''