Enable url lookup without a proxy

By introducing a use_proxy parameter to url lookup, the usage of proxy
is totally controllable.
This commit is contained in:
Jacky Hu 2017-04-20 22:43:25 +08:00
parent 0b585ec4fd
commit 11e4e51235

View file

@ -36,12 +36,13 @@ class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
validate_certs = kwargs.get('validate_certs', True)
use_proxy = kwargs.get('use_proxy', True)
ret = []
for term in terms:
display.vvvv("url lookup connecting to %s" % term)
try:
response = open_url(term, validate_certs=validate_certs)
response = open_url(term, validate_certs=validate_certs, use_proxy=use_proxy)
except HTTPError as e:
raise AnsibleError("Received HTTP error for %s : %s" % (term, str(e)))
except URLError as e: