From 2276c5f2060a46d556268b846e6ef30950d992cc Mon Sep 17 00:00:00 2001 From: Will Thames Date: Mon, 7 Aug 2017 22:36:51 +1000 Subject: [PATCH] apt: Update cache if cache_valid_time is set (#27618) It's not clear from the docs whether you need to set `update_cache` when using `cache_valid_time`. Setting `cache_valid_time` should imply `update_cache`. Update docs to reflect this. --- lib/ansible/modules/packaging/os/apt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/packaging/os/apt.py b/lib/ansible/modules/packaging/os/apt.py index 9b5e8b30099..2e090660e63 100644 --- a/lib/ansible/modules/packaging/os/apt.py +++ b/lib/ansible/modules/packaging/os/apt.py @@ -49,6 +49,7 @@ options: cache_valid_time: description: - Update the apt cache if its older than the I(cache_valid_time). This option is set in seconds. + As of Ansible 2.4, this implicitly sets I(update_cache) if set. required: false default: 0 purge: @@ -926,7 +927,7 @@ def main(): # Cache valid time is default 0, which will update the cache if # needed and `update_cache` was set to true updated_cache = False - if p['update_cache']: + if p['update_cache'] or p['cache_valid_time']: now = datetime.datetime.now() tdelta = datetime.timedelta(seconds=p['cache_valid_time']) if not mtimestamp + tdelta >= now: