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

openbsd_pkg: Fix KeyError (#3336)

If package installation has an error after the package is install (e.g.
when running tags), then there will be output on stderr and the fallback
regex will match; however, since pkg_add exited non-zero, changed is
never added as a key to the dictionary. As a result the code at the end
of main that checks if anything has changed raises a KeyError.
This commit is contained in:
Matthew Martin 2021-09-20 17:19:04 +00:00 committed by GitHub
parent 9ce1009643
commit 02d0e3d286
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
bugfixes:
- openbsd_pkg - fix crash from ``KeyError`` exception when package installs,
but ``pkg_add`` returns with a non-zero exit code
(https://github.com/ansible-collections/community.general/pull/3336).

View file

@ -246,6 +246,7 @@ def package_present(names, pkg_spec, module):
if match: if match:
# It turns out we were able to install the package. # It turns out we were able to install the package.
module.debug("package_present(): we were able to install package for name '%s'" % name) module.debug("package_present(): we were able to install package for name '%s'" % name)
pkg_spec[name]['changed'] = True
else: else:
# We really did fail, fake the return code. # We really did fail, fake the return code.
module.debug("package_present(): we really did fail for name '%s'" % name) module.debug("package_present(): we really did fail for name '%s'" % name)