From 7cf7dff3a6d086c6155cb06e1107d447b7fbce66 Mon Sep 17 00:00:00 2001 From: rebtoor <538845+rebtoor@users.noreply.github.com> Date: Wed, 10 Jul 2024 18:02:51 +0200 Subject: [PATCH] Ensure that we are handling DownloadError properly in the dnf module (#83543) Signed-off-by: Roberto Alfieri --- changelogs/fragments/dnf_handle_downloaderror.yml | 2 ++ lib/ansible/modules/dnf.py | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/dnf_handle_downloaderror.yml diff --git a/changelogs/fragments/dnf_handle_downloaderror.yml b/changelogs/fragments/dnf_handle_downloaderror.yml new file mode 100644 index 00000000000..ec4e0e147f4 --- /dev/null +++ b/changelogs/fragments/dnf_handle_downloaderror.yml @@ -0,0 +1,2 @@ +bugfixes: + - dnf - Ensure that we are handling DownloadError properly in the dnf module diff --git a/lib/ansible/modules/dnf.py b/lib/ansible/modules/dnf.py index 0efb0091585..b40d999f945 100644 --- a/lib/ansible/modules/dnf.py +++ b/lib/ansible/modules/dnf.py @@ -1197,10 +1197,8 @@ class DnfModule(YumDnf): self.base.download_packages(self.base.transaction.install_set) except dnf.exceptions.DownloadError as e: - self.module.fail_json( - msg="Failed to download packages: {0}".format(to_text(e)), - results=[], - ) + failure_response['msg'] = "Failed to download packages: {0}".format(to_native(e)) + self.module.fail_json(**failure_response) # Validate GPG. This is NOT done in dnf.Base (it's done in the # upstream CLI subclass of dnf.Base)