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
This commit is contained in:
Greg Hellings 2018-12-13 04:22:53 -06:00 committed by ansibot
parent 69988cfca0
commit af5d84b70b

View file

@ -1087,10 +1087,10 @@ class DnfModule(YumDnf):
self.module.exit_json(**response)
else:
response['changed'] = True
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)
if self.module.check_mode:
response['msg'] = "Check mode: No changes made, but would have if not in check mode"
self.module.exit_json(**response)