Fix var lookup plugin to return a list

This commit is contained in:
Toshio Kuratomi 2018-02-07 15:48:35 -08:00
parent 33cbbe0b39
commit 59faad3a6b

View file

@ -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