From 0e0e5097a95ae7606613f8096e5159792de72e15 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Thu, 11 May 2017 12:26:32 +0200 Subject: [PATCH] Optionally return raw data from URL lookup using split_lines=False --- lib/ansible/plugins/lookup/url.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ansible/plugins/lookup/url.py b/lib/ansible/plugins/lookup/url.py index 2686543c307..135256d1dcb 100644 --- a/lib/ansible/plugins/lookup/url.py +++ b/lib/ansible/plugins/lookup/url.py @@ -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