1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fix(homebrew): give correct error message when become true used (#8048)

* fix(homebrew): give correct error message when become true used

This commit fixes #8047 by raising the exception coming from calling
homebrew with the `become: true` parameter set.

* chore(changelog): add changelog fragment
This commit is contained in:
Michael Wall 2024-03-08 06:24:56 +00:00 committed by GitHub
parent 98df344017
commit fa30b02294
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- homebrew - error returned from brew command was ignored and tried to parse empty JSON. Fix now checks for an error and raises it to give accurate error message to users (https://github.com/ansible-collections/community.general/issues/8047).

View file

@ -488,6 +488,10 @@ class Homebrew(object):
self.current_package, self.current_package,
] ]
rc, out, err = self.module.run_command(cmd) rc, out, err = self.module.run_command(cmd)
if err:
self.failed = True
self.message = err.strip()
raise HomebrewException(self.message)
data = json.loads(out) data = json.loads(out)
return _check_package_in_json(data, "formulae") or _check_package_in_json(data, "casks") return _check_package_in_json(data, "formulae") or _check_package_in_json(data, "casks")