[stable-8] Fix the homebrew module failing because of warnings () ()

Fix the homebrew module failing because of warnings ()

Instead of checking if there is an error message, which can also be a
warning, we now check the return code.

This commit fixes  

Co-authored-by: Strahinja Kustudic <strahinjak@nordeus.com>
(cherry picked from commit 43cb5a0d54)

Co-authored-by: Strahinja Kustudic <kustodian@gmail.com>
This commit is contained in:
Felix Fontein 2024-06-01 21:32:38 +02:00 committed by GitHub
parent 4c6d439a13
commit 03d944be9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions
changelogs/fragments
plugins/modules

View file

@ -0,0 +1,2 @@
bugfixes:
- homebrew - do not fail when brew prints warnings (https://github.com/ansible-collections/community.general/pull/8406, https://github.com/ansible-collections/community.general/issues/7044).

View file

@ -488,9 +488,9 @@ class Homebrew(object):
self.current_package,
]
rc, out, err = self.module.run_command(cmd)
if err:
if rc != 0:
self.failed = True
self.message = err.strip()
self.message = err.strip() or ("Unknown failure with exit code %d" % rc)
raise HomebrewException(self.message)
data = json.loads(out)