From 24137a3c6ce63eaa674e8468afaa90f4841d001f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Moser?= Date: Sun, 28 Sep 2014 20:30:39 +0200 Subject: [PATCH] yum: add update_cache option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- packaging/os/yum.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packaging/os/yum.py b/packaging/os/yum.py index c3158077d18..73fbb699e75 100644 --- a/packaging/os/yum.py +++ b/packaging/os/yum.py @@ -96,6 +96,16 @@ options: choices: ["yes", "no"] 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: [] # informational: requirements for nodes requirements: [ yum, rpm ] @@ -746,6 +756,10 @@ def ensure(module, state, pkgspec, conf_file, enablerepo, disablerepo, yum_basecmd.extend(r_cmd) if state in ['installed', 'present', 'latest']: + + if module.params.get('update_cache'): + module.run_command(yum_basecmd + ['makecache']) + my = yum_base(conf_file) try: for r in dis_repos: @@ -803,6 +817,7 @@ def main(): list=dict(), conf_file=dict(default=None), 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 install_repoquery=dict(required=False, default="yes", type='bool'), ),