Handle fetch_url error gracefully (#23821)

Fix adds http response code check for fetch_url.
Also, method in fetch_url call.

Fixes https://github.com/ansible/ansible/issues/23800

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/24056/head
Abhijeet Kasurde 8 years ago committed by Matt Martz
parent d02a9016a2
commit 86a63cfcd7

@ -722,7 +722,10 @@ def download(module, deb):
BUFSIZE = 65536
try:
rsp, info = fetch_url(module, deb)
rsp, info = fetch_url(module, deb, method='GET')
if info['status'] != 200:
module.fail_json(msg="Failed to download %s, %s" % (deb,
info['msg']))
# Ensure file is open in binary mode for Python 3
f = open(package, 'wb')
# Read 1kb at a time to save on ram

Loading…
Cancel
Save