mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 22:33:25 +00:00
Make all lookup plugins work with lists
Lookup plugins should accept a string or a list, and always return a list, even if it is just one item.
This commit is contained in:
@@ -24,7 +24,12 @@ class LookupModule(object):
|
||||
self.basedir = basedir
|
||||
|
||||
def run(self, terms, **kwargs):
|
||||
path = utils.path_dwim(self.basedir, terms)
|
||||
if not os.path.exists(path):
|
||||
raise errors.AnsibleError("%s does not exist" % path)
|
||||
return [open(path).read().rstrip()]
|
||||
if isinstance(terms, basestring):
|
||||
terms = [ terms ]
|
||||
ret = []
|
||||
for term in terms:
|
||||
path = utils.path_dwim(self.basedir, term)
|
||||
if not os.path.exists(path):
|
||||
raise errors.AnsibleError("%s does not exist" % path)
|
||||
ret.append(open(path).read().rstrip())
|
||||
return ret
|
||||
|
||||
Reference in New Issue
Block a user