From e1761d7724186a094f69bebb4f448e16e7aeb0d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20L=C3=B3pez?= Date: Tue, 14 Feb 2017 18:53:14 +0100 Subject: [PATCH] yum: improve disk usage when update_cache used (#21098) * Marks metadata files as outdated Eliminates time records of the metadata and mirrorlists download for each repository. This forces yum to revalidate the cache for each repository the next time it is used. * Command arguments in two separate strings to be compatible if run_command implementation changes. Doc explains a little better what is that parameter doing --- lib/ansible/modules/packaging/os/yum.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/packaging/os/yum.py b/lib/ansible/modules/packaging/os/yum.py index 4b85fd6f472..0b8fe71e1cd 100644 --- a/lib/ansible/modules/packaging/os/yum.py +++ b/lib/ansible/modules/packaging/os/yum.py @@ -96,13 +96,13 @@ options: update_cache: description: - - Force updating the cache. Has an effect only if state is I(present) - or I(latest). + - Force yum to check if cache is out of date and redownload if needed. + Has an effect only if state is I(present) or I(latest). required: false version_added: "1.9" default: "no" choices: ["yes", "no"] - aliases: [] + aliases: [ "expire-cache" ] validate_certs: description: @@ -1081,7 +1081,7 @@ def ensure(module, state, pkgs, conf_file, enablerepo, disablerepo, if state in ['installed', 'present', 'latest']: if module.params.get('update_cache'): - module.run_command(yum_basecmd + ['makecache']) + module.run_command(yum_basecmd + ['clean', 'expire-cache']) my = yum_base(conf_file, installroot) try: @@ -1145,7 +1145,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'), + update_cache=dict(required=False, default="no", aliases=['expire-cache'], type='bool'), validate_certs=dict(required=False, default="yes", type='bool'), installroot=dict(required=False, default="/", type='str'), # this should not be needed, but exists as a failsafe