Skip to content

Commit

Permalink
[PR #6785/704a3019 backport][stable-6] Handle pkg_info(1) error messa…
Browse files Browse the repository at this point in the history
…ge "Can't find" (#6892)

Handle pkg_info(1) error message "Can't find" (#6785)

* Handle pkg_info(1) error message "Can't find"

* Update plugins/modules/openbsd_pkg.py

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 704a301)

Co-authored-by: Rafael Sadowski <rafael@sizeofvoid.org>
  • Loading branch information
patchback[bot] and sizeofvoid authored Jul 8, 2023
1 parent 9ecfa37 commit 1a4ae5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/6785-openbsd_pkg_pkg_info_handling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- openbsd_pkg - the pkg_info(1) behavior has changed in OpenBSD >7.3. The error message ``Can't find`` should not lead to an error case (https://github.com/ansible-collections/community.general/pull/6785).
6 changes: 5 additions & 1 deletion plugins/modules/openbsd_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ def get_package_state(names, pkg_spec, module):
rc, stdout, stderr = execute_command(command, module)

if stderr:
module.fail_json(msg="failed in get_package_state(): " + stderr)
match = re.search(r"^Can't find inst:%s$" % re.escape(name), stderr)
if match:
pkg_spec[name]['installed_state'] = False
else:
module.fail_json(msg="failed in get_package_state(): " + stderr)

if stdout:
# If the requested package name is just a stem, like "python", we may
Expand Down

0 comments on commit 1a4ae5e

Please sign in to comment.