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

Add cache_updated return value.

This commit is contained in:
Felix Fontein 2022-03-08 07:53:52 +01:00
parent 23a92c0fd5
commit 367297bb5c
2 changed files with 19 additions and 0 deletions

View file

@ -1,6 +1,9 @@
bugfixes:
- "pacman - make sure that ``packages`` is always returned when ``name`` or ``upgrade`` is specified, also if nothing is done
(https://github.com/ansible-collections/community.general/pull/4329)."
minor_changes:
- "pacman - add ``cache_updated`` return value to when ``update_cache=true``
(https://github.com/ansible-collections/community.general/pull/4329)."
deprecated_features:
- "pacman - from community.general 5.0.0 on, the ``changed`` status of ``update_cache`` will no longer be ignored if ``name`` or ``upgrade`` is specified.
To keep the old behavior, add something like ``register: result`` and ``changed_when: result.packages | length > 0`` to your task

View file

@ -125,6 +125,15 @@ packages:
elements: str
sample: [ package, other-package ]
cache_updated:
description:
- The changed status of C(pacman -Sy).
- Useful when I(name) or I(upgrade=true) are specified next to I(update_cache=true).
returned: success, when I(update_cache=true)
type: bool
sample: false
version_added: 4.6.0
stdout:
description:
- Output from pacman.
@ -512,6 +521,7 @@ class Pacman(object):
if self.m.check_mode:
self.add_exit_infos("Would have updated the package db")
self.changed = True
self.exit_params["cache_updated"] = True
return
cmd = [
@ -526,7 +536,13 @@ class Pacman(object):
rc, stdout, stderr = self.m.run_command(cmd, check_rc=False)
# TODO: check whether the cache was actually updated
# Right now, this only seems to be possible by adding `--debug` and looking
# for `.db: response code` and checking whether the response is 304 (not
# updated) or something else (likely updated)
self.changed = True
self.exit_params["cache_updated"] = True
if rc == 0:
self.add_exit_infos("Updated package db", stdout=stdout, stderr=stderr)