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/4420/head
parent
d02a9016a2
commit
86a63cfcd7
|
@ -722,7 +722,10 @@ def download(module, deb):
|
||||||
BUFSIZE = 65536
|
BUFSIZE = 65536
|
||||||
|
|
||||||
try:
|
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
|
# Ensure file is open in binary mode for Python 3
|
||||||
f = open(package, 'wb')
|
f = open(package, 'wb')
|
||||||
# Read 1kb at a time to save on ram
|
# Read 1kb at a time to save on ram
|
||||||
|
|
Loading…
Reference in New Issue