yum: add update_cache option
Yum does not always update to latest package version unless metadata cache has expired. By runing yum makecache, we ensure the metadata cache has been updated. Signed-off-by: René Moser <mail@renemoser.net>
This commit is contained in:
parent
4035d24313
commit
24137a3c6c
1 changed files with 15 additions and 0 deletions
|
@ -96,6 +96,16 @@ options:
|
||||||
choices: ["yes", "no"]
|
choices: ["yes", "no"]
|
||||||
aliases: []
|
aliases: []
|
||||||
|
|
||||||
|
update_cache:
|
||||||
|
description:
|
||||||
|
- Force updating the cache. Has an effect only if state is I(present)
|
||||||
|
or I(latest).
|
||||||
|
required: false
|
||||||
|
version_added: "1.9"
|
||||||
|
default: "no"
|
||||||
|
choices: ["yes", "no"]
|
||||||
|
aliases: []
|
||||||
|
|
||||||
notes: []
|
notes: []
|
||||||
# informational: requirements for nodes
|
# informational: requirements for nodes
|
||||||
requirements: [ yum, rpm ]
|
requirements: [ yum, rpm ]
|
||||||
|
@ -746,6 +756,10 @@ def ensure(module, state, pkgspec, conf_file, enablerepo, disablerepo,
|
||||||
yum_basecmd.extend(r_cmd)
|
yum_basecmd.extend(r_cmd)
|
||||||
|
|
||||||
if state in ['installed', 'present', 'latest']:
|
if state in ['installed', 'present', 'latest']:
|
||||||
|
|
||||||
|
if module.params.get('update_cache'):
|
||||||
|
module.run_command(yum_basecmd + ['makecache'])
|
||||||
|
|
||||||
my = yum_base(conf_file)
|
my = yum_base(conf_file)
|
||||||
try:
|
try:
|
||||||
for r in dis_repos:
|
for r in dis_repos:
|
||||||
|
@ -803,6 +817,7 @@ def main():
|
||||||
list=dict(),
|
list=dict(),
|
||||||
conf_file=dict(default=None),
|
conf_file=dict(default=None),
|
||||||
disable_gpg_check=dict(required=False, default="no", type='bool'),
|
disable_gpg_check=dict(required=False, default="no", type='bool'),
|
||||||
|
update_cache=dict(required=False, default="no", type='bool'),
|
||||||
# this should not be needed, but exists as a failsafe
|
# this should not be needed, but exists as a failsafe
|
||||||
install_repoquery=dict(required=False, default="yes", type='bool'),
|
install_repoquery=dict(required=False, default="yes", type='bool'),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue