From 03d944be9a60cbcef0f82c9134989d7649a99042 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 1 Jun 2024 21:32:38 +0200 Subject: [PATCH] [stable-8] Fix the homebrew module failing because of warnings (#8406) (#8429) Fix the homebrew module failing because of warnings (#8406) Instead of checking if there is an error message, which can also be a warning, we now check the return code. This commit fixes #8229 #7044 Co-authored-by: Strahinja Kustudic (cherry picked from commit 43cb5a0d54856f1f09026e476a5b8ee03b44cf0b) Co-authored-by: Strahinja Kustudic --- changelogs/fragments/8406-fix-homebrew-cask-warning.yaml | 2 ++ plugins/modules/homebrew.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/8406-fix-homebrew-cask-warning.yaml diff --git a/changelogs/fragments/8406-fix-homebrew-cask-warning.yaml b/changelogs/fragments/8406-fix-homebrew-cask-warning.yaml new file mode 100644 index 0000000000..0e3bf38ed3 --- /dev/null +++ b/changelogs/fragments/8406-fix-homebrew-cask-warning.yaml @@ -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). diff --git a/plugins/modules/homebrew.py b/plugins/modules/homebrew.py index 5d471797a7..e548a2d8a0 100644 --- a/plugins/modules/homebrew.py +++ b/plugins/modules/homebrew.py @@ -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)