From af5d84b70b1b87ef6e6b1bc6bbf7cff6f5560780 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Thu, 13 Dec 2018 04:22:53 -0600 Subject: [PATCH] Properly report install failures from dnf module (#49760) Reporting of install failures was improperly guarded behind a list of packages to install when the first element changed in a list was found. This lead to the dnf module silently failing at times when it should not fail. Fixes issue 49759 --- lib/ansible/modules/packaging/os/dnf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/packaging/os/dnf.py b/lib/ansible/modules/packaging/os/dnf.py index d8c2e14787e..08602e53eec 100644 --- a/lib/ansible/modules/packaging/os/dnf.py +++ b/lib/ansible/modules/packaging/os/dnf.py @@ -1087,10 +1087,10 @@ class DnfModule(YumDnf): self.module.exit_json(**response) else: response['changed'] = True + if failure_response['failures']: + failure_response['msg'] = 'Failed to install some of the specified packages', + self.module.fail_json(**failure_response) if self.module.check_mode: - if failure_response['failures']: - failure_response['msg'] = 'Failed to install some of the specified packages', - self.module.fail_json(**failure_response) response['msg'] = "Check mode: No changes made, but would have if not in check mode" self.module.exit_json(**response)