1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Optionally return raw data from URL lookup using split_lines=False

This commit is contained in:
Jan-Piet Mens 2017-05-11 12:26:32 +02:00 committed by Brian Coca
parent 91b87d4cbb
commit 0e0e5097a9

View file

@ -36,6 +36,7 @@ class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
validate_certs = kwargs.get('validate_certs', True)
split_lines = kwargs.get('split_lines', True)
ret = []
for term in terms:
@ -51,6 +52,9 @@ class LookupModule(LookupBase):
except ConnectionError as e:
raise AnsibleError("Error connecting to %s: %s" % (term, str(e)))
for line in response.read().splitlines():
ret.append(to_text(line))
if split_lines:
for line in response.read().splitlines():
ret.append(to_text(line))
else:
ret.append(to_text(response.read()))
return ret