Fix dnf module crash for non-existent url (#81801)

* ci_complete ci_coverage
pull/81858/head
Sloane Hertel 8 months ago committed by GitHub
parent 116766ac3e
commit b3408ab80b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Fix handling missing urls in ansible.module_utils.urls.fetch_file for Python 3.

@ -2058,7 +2058,7 @@ def fetch_file(module, url, data=None, headers=None, method=None,
try:
rsp, info = fetch_url(module, url, data, headers, method, use_proxy, force, last_mod_time, timeout,
unredirected_headers=unredirected_headers, decompress=decompress, ciphers=ciphers)
if not rsp:
if not rsp or (rsp.code and rsp.code >= 400):
module.fail_json(msg="Failure downloading %s, %s" % (url, info['msg']))
data = rsp.read(bufsize)
while data:

@ -510,6 +510,7 @@
that:
- "dnf_result is failed"
- "not dnf_result.changed"
- "'Failure downloading' in dnf_result.msg or 'Failed to download' in dnf_result.msg"
- name: verify dnf module outputs
assert:

Loading…
Cancel
Save