Fix var lookup plugin to return a list

pull/35910/head
Toshio Kuratomi 7 years ago
parent 33cbbe0b39
commit 59faad3a6b

@ -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…
Cancel
Save