diff --git a/changelogs/fragments/6785-openbsd_pkg_pkg_info_handling.yml b/changelogs/fragments/6785-openbsd_pkg_pkg_info_handling.yml new file mode 100644 index 0000000000..081411a602 --- /dev/null +++ b/changelogs/fragments/6785-openbsd_pkg_pkg_info_handling.yml @@ -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). diff --git a/plugins/modules/openbsd_pkg.py b/plugins/modules/openbsd_pkg.py index 0f3376aa88..c831136110 100644 --- a/plugins/modules/openbsd_pkg.py +++ b/plugins/modules/openbsd_pkg.py @@ -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