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

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>
This commit is contained in:
Rafael Sadowski 2023-07-08 10:12:42 +02:00 committed by GitHub
parent fc74f9a4f2
commit 704a3019b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -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).

View file

@ -169,7 +169,11 @@ def get_package_state(names, pkg_spec, module):
rc, stdout, stderr = execute_command(command, module) rc, stdout, stderr = execute_command(command, module)
if stderr: 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 stdout:
# If the requested package name is just a stem, like "python", we may # If the requested package name is just a stem, like "python", we may