Fix var lookup plugin to return a list
This commit is contained in:
parent
33cbbe0b39
commit
59faad3a6b
1 changed files with 5 additions and 4 deletions
|
@ -64,7 +64,7 @@ class LookupModule(LookupBase):
|
|||
|
||||
def run(self, terms, variables=None, **kwargs):
|
||||
|
||||
ret = None
|
||||
ret = []
|
||||
if variables is not None:
|
||||
self._templar.set_available_variables(variables)
|
||||
myvars = getattr(self._templar, '_available_variables', {})
|
||||
|
@ -91,10 +91,11 @@ class LookupModule(LookupBase):
|
|||
value = myvars['hostvars'][term]
|
||||
else:
|
||||
raise AnsibleUndefinedVariable('No variable found with this name: %s' % term)
|
||||
ret = self._templar.template(value, fail_on_undefined=True)
|
||||
ret = [self._templar.template(value, fail_on_undefined=True)]
|
||||
except AnsibleUndefinedVariable:
|
||||
if default is None:
|
||||
ret = default
|
||||
if default is not None:
|
||||
ret = [default]
|
||||
else:
|
||||
raise
|
||||
|
||||
return ret
|
||||
|
|
Loading…
Reference in a new issue