1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/plugins/modules/packaging/os
Jean Raby 1580f3c2b4
request for comments - pacman: speed up most operations when working with a package list (#3907)
* pacman: rewrite with a cache to speed up execution

- Use a cache (or inventory) to speed up lookups of:
  - installed packages and groups
  - available packages and groups
  - upgradable packages
- Call pacman with the list of pkgs instead of one call per package (for
  installations, upgrades and removals)
- Use pacman [--sync|--upgrade] --print-format [...] to gather list of
  changes. Parsing that instead of the regular output of pacman, which
  is error prone and can be changed by user configuration.
  This can introduce a TOCTOU problem but unless something else calls
  pacman between the invocations, it shouldn't be a concern.
- Given the above, "check mode" code is within the function that would
  carry out the actual operation. This should make it harder for the
  check code and the "real code" to diverge.
- Support for specifying alternate package name formats is a bit more
  robust. pacman is used to extract the name of the package when the
  specified package is a file or a URL.
  The "<repo>/<pkgname>" format is also supported.

For "state: latest" with a list of ~35 pkgs, this module is about 5
times faster than the original.

* Let fail() actually work

* all unhappy paths now end up calling fail()

* Update copyright

* Argument changes

update_cache_extra_args handled as a list like the others
moved the module setup to its own function for easier testing
update and upgrade have no defaults (None) to let required_one_of() do
its job properly

* update_cache exit path

Shift successful exit without name or upgrade under "update_cache".

It is an error if name or upgrade isn't specified and update_cache wasn't specified
either. (Caught by ansiblemodule required_one_of but still)

* Add pkgs to output on success only

Also align both format, only pkg name for now

* Multiple fixes

Move VersionTuple to top level for import from tests
Add removed pkgs to the exit json when removing packages
fixup list of upgraded pkgs reported on upgrades (was tuple of list for
no reason)
use list idiom for upgrades, like the rest
drop unused expand_package_groups function
skip empty lines when building inventory

* pacman: add tests

* python 2.x compat + pep8

* python 2.x some more

* Fix failure when pacman emits warnings

Add tests covering that failure case

* typo

* Whitespace

black failed me...

* Adjust documentation to fit implicit defaults

* fix test failures on older pythons

* remove file not intended for commit

* Test exception str with e.match

* Build inventory after cache update + adjust tests

* Apply suggestions from code review

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

* Update plugins/modules/packaging/os/pacman.py

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

* changelog

* bump copyright year and add my name to authors

* Update changelogs/fragments/3907-pacman-speedup.yml

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

* maintainer entry

Co-authored-by: Felix Fontein <felix@fontein.de>
2022-02-08 22:46:00 +01:00
..
apk.py Tidy up validate-modules ignores for packaging modules (#1289) 2020-11-13 12:41:11 +00:00
apt_repo.py modules: fix examples to use FQCN (#644) 2020-07-13 21:50:31 +02:00
apt_rpm.py Deprecation of parameters triggering the parameter-invalid sanity-check (#1927) 2021-03-05 08:17:36 +01:00
copr.py Fix copr integration tests (#3237) 2021-09-01 22:58:10 +02:00
dnf_versionlock.py dnf_versionlock: new module (#3552) 2021-10-27 22:36:48 +02:00
flatpak.py Prepare for distutils.version being removed in Python 3.12 (#3936) 2021-12-24 17:34:48 +00:00
flatpak_remote.py Replace ansible.module_utils._text by ansible.module_utils.common.text.converters (#2877) 2021-06-26 23:59:11 +02:00
homebrew.py Fixed typo in homebrew documentation (#3577) 2021-10-18 22:43:57 +02:00
homebrew_cask.py homebrew_cask: reinstall when force is install option (#4090) 2022-02-02 21:31:05 +01:00
homebrew_tap.py homebrew_tap: Add support for brew search path (#1708) 2021-02-01 08:42:32 +01:00
installp.py modules: fix examples to use FQCN (#644) 2020-07-13 21:50:31 +02:00
layman.py modules: fix examples to use FQCN (#644) 2020-07-13 21:50:31 +02:00
macports.py macports: add stdout and stderr to status (#3499) (#3500) 2021-10-11 06:55:09 +02:00
mas.py Prepare for distutils.version being removed in Python 3.12 (#3936) 2021-12-24 17:34:48 +00:00
openbsd_pkg.py Prepare for distutils.version being removed in Python 3.12 (#3936) 2021-12-24 17:34:48 +00:00
opkg.py Improve opkg module (#3554) 2021-10-14 21:14:32 +02:00
pacman.py request for comments - pacman: speed up most operations when working with a package list (#3907) 2022-02-08 22:46:00 +01:00
pacman_key.py Replace ansible.module_utils._text by ansible.module_utils.common.text.converters (#2877) 2021-06-26 23:59:11 +02:00
pkg5.py Tidy up validate-modules ignores for packaging modules (#1289) 2020-11-13 12:41:11 +00:00
pkg5_publisher.py modules: fix examples to use FQCN (#644) 2020-07-13 21:50:31 +02:00
pkgin.py Fix exception in pkgin module when all packages are already installed (#3583) 2021-10-22 07:47:27 +02:00
pkgng.py pkgng: add basic integration tests (#3526) 2021-10-22 07:32:35 +02:00
pkgutil.py fixed calls to list.extend() (#2161) 2021-04-04 23:38:59 +02:00
portage.py Replace ansible.module_utils._text by ansible.module_utils.common.text.converters (#2877) 2021-06-26 23:59:11 +02:00
portinstall.py modules: fix examples to use FQCN (#644) 2020-07-13 21:50:31 +02:00
pulp_repo.py Add a Pulp 2 related note to pulp_repo (#2096) 2021-03-24 17:48:24 +01:00
redhat_subscription.py mass-added the utf-8 marker (#3163) 2021-08-08 10:40:22 +02:00
rhn_channel.py mass-added the utf-8 marker (#3163) 2021-08-08 10:40:22 +02:00
rhn_register.py rhn_register: added force option to allow forced registering (#1454) (#1455) 2020-12-08 13:12:04 +01:00
rhsm_release.py mass-added the utf-8 marker (#3163) 2021-08-08 10:40:22 +02:00
rhsm_repository.py mass-added the utf-8 marker (#3163) 2021-08-08 10:40:22 +02:00
rpm_ostree_pkg.py mass-added the utf-8 marker (#3163) 2021-08-08 10:40:22 +02:00
slackpkg.py Deprecation of parameters triggering the parameter-invalid sanity-check (#1927) 2021-03-05 08:17:36 +01:00
snap.py Fix version_added. 2022-01-24 06:41:41 +01:00
snap_alias.py fix modules' output by using publish_cmd (#3655) 2021-11-01 13:53:02 +01:00
sorcery.py modules: fix examples to use FQCN (#644) 2020-07-13 21:50:31 +02:00
svr4pkg.py Fix #2373 - TypeError: a bytes-like object is required, not 'str' (#2375) 2021-05-03 07:25:08 +02:00
swdepot.py modules: fix examples to use FQCN (#644) 2020-07-13 21:50:31 +02:00
swupd.py mass-added the utf-8 marker (#3163) 2021-08-08 10:40:22 +02:00
urpmi.py Deprecation of parameters triggering the parameter-invalid sanity-check (#1927) 2021-03-05 08:17:36 +01:00
xbps.py Remove deprecated features scheduled for removal in 3.0.0 (#1926) 2021-03-09 21:23:20 +01:00
yum_versionlock.py yum_versionlock: fix idempotency when using wildcard (asterisk) (#2787) 2021-06-27 16:40:49 +02:00
zypper.py zypper: support transactional-updates (#3164) 2021-08-12 08:17:03 +02:00
zypper_repository.py Prepare for distutils.version being removed in Python 3.12 (#3936) 2021-12-24 17:34:48 +00:00