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): def run(self, terms, variables=None, **kwargs):
ret = None ret = []
if variables is not None: if variables is not None:
self._templar.set_available_variables(variables) self._templar.set_available_variables(variables)
myvars = getattr(self._templar, '_available_variables', {}) myvars = getattr(self._templar, '_available_variables', {})
@ -91,10 +91,11 @@ class LookupModule(LookupBase):
value = myvars['hostvars'][term] value = myvars['hostvars'][term]
else: else:
raise AnsibleUndefinedVariable('No variable found with this name: %s' % term) 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: except AnsibleUndefinedVariable:
if default is None: if default is not None:
ret = default ret = [default]
else: else:
raise raise
return ret return ret

Loading…
Cancel
Save