diff --git a/lib/ansible/module_utils/urls.py b/lib/ansible/module_utils/urls.py index 0c00fe87be9..26185672864 100644 --- a/lib/ansible/module_utils/urls.py +++ b/lib/ansible/module_utils/urls.py @@ -897,7 +897,11 @@ def fetch_url(module, url, data=None, headers=None, method=None, except (ConnectionError, ValueError), e: module.fail_json(msg=str(e)) except urllib2.HTTPError, e: - info.update(dict(msg=str(e), status=e.code, **e.info())) + try: + body = e.read() + except AttributeError: + body = '' + info.update(dict(msg=str(e), status=e.code, body=body, **e.info())) except urllib2.URLError, e: code = int(getattr(e, 'code', -1)) info.update(dict(msg="Request failed: %s" % str(e), status=code))