summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2014-05-19 23:04:13 -0500
committerJames Cammarata <jimi@sngx.net>2014-05-21 14:59:58 -0500
commit362626d07c2482d883403c498b74924a7dd7ec7f (patch)
treea60545e8f1f7f98b13bc66abba2252360737c2c5
parenta54b8764fa6cbfee10ead9fc8501c2a3f471d02a (diff)
downloadansible-362626d07c2482d883403c498b74924a7dd7ec7f.tar.gz
Default use_proxy to True for fetch_url()
Also added some error handling to the fetch_url() call in the apt_repository module, so that failures to look up the PPA info are properly handled. Fixes #7322
-rw-r--r--lib/ansible/module_utils/urls.py2
-rw-r--r--library/packaging/apt_repository2
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py
index d80ea76bf8..15faadeb55 100644
--- a/lib/ansible/module_utils/urls.py
+++ b/lib/ansible/module_utils/urls.py
@@ -207,7 +207,7 @@ def url_argument_spec():
def fetch_url(module, url, data=None, headers=None, method=None,
- use_proxy=False, force=False, last_mod_time=None, timeout=10):
+ use_proxy=True, force=False, last_mod_time=None, timeout=10):
'''
Fetches a file from an HTTP/FTP server using urllib2
'''
diff --git a/library/packaging/apt_repository b/library/packaging/apt_repository
index a33c5735a8..e10d2c5492 100644
--- a/library/packaging/apt_repository
+++ b/library/packaging/apt_repository
@@ -320,6 +320,8 @@ class UbuntuSourcesList(SourcesList):
headers = dict(Accept='application/json')
response, info = fetch_url(self.module, lp_api, headers=headers)
+ if info['status'] != 200:
+ self.module.fail_json(msg="failed to fetch PPA information, error was: %s" % info['msg'])
return json.load(response)
def _expand_ppa(self, path):