mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
allow update_cache as stand alone operation for yum/dnf (#46183)
* allow update_cache as stand alone operation for yum/dnf Fixes #40068 Signed-off-by: Adam Miller <admiller@redhat.com> * make sanity tests happy Signed-off-by: Adam Miller <admiller@redhat.com>
This commit is contained in:
parent
960dfa862b
commit
c8ed5c29e9
4 changed files with 49 additions and 3 deletions
|
@ -1461,6 +1461,23 @@ class YumModule(YumDnf):
|
|||
if error_msgs:
|
||||
self.module.fail_json(msg='. '.join(error_msgs))
|
||||
|
||||
if self.update_cache and not self.names and not self.list:
|
||||
rc, stdout, stderr = self.module.run_command(self.yum_basecmd + ['clean', 'expire-cache'])
|
||||
if rc == 0:
|
||||
self.module.exit_json(
|
||||
changed=False,
|
||||
msg="Cache updated",
|
||||
rc=rc,
|
||||
results=[]
|
||||
)
|
||||
else:
|
||||
self.module.exit_json(
|
||||
changed=False,
|
||||
msg="Failed to update cache",
|
||||
rc=rc,
|
||||
results=[stderr],
|
||||
)
|
||||
|
||||
# fedora will redirect yum to dnf, which has incompatibilities
|
||||
# with how this module expects yum to operate. If yum-deprecated
|
||||
# is available, use that instead to emulate the old behaviors.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue