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 '''
ifkin('action','local_action'):
returnself._load_action
elifkinutils.plugins.module_finder:
returnself._load_module
elifk.startswith('with_'):
returnself._load_loop
elifk=='changed_when':
returnself._load_changed_when
elifk=='failed_when':
returnself._load_failed_when
elifk=='when':
returnself._load_when
elifk=='tags':
returnself._load_tags
elifknotinself.VALID_KEYS:
returnself._load_invalid_key
else:
returnself._load_other_valid_key
@classmethod
defload(self,ds,block=None,role=None):
''' walk the datastructure and store/validate parameters '''