From 3664c74cb80e5a7c5181afd6e9136c892444089b Mon Sep 17 00:00:00 2001 From: jjshoe Date: Tue, 17 Apr 2018 08:33:22 -0500 Subject: [PATCH] Fix idempotency in apt module (#38858) * Idempotency fix Only show a change, if we did indeed update the cache. * Apply changes from review feedback --- lib/ansible/modules/packaging/os/apt.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/packaging/os/apt.py b/lib/ansible/modules/packaging/os/apt.py index f0167705a2..67d4388cd8 100644 --- a/lib/ansible/modules/packaging/os/apt.py +++ b/lib/ansible/modules/packaging/os/apt.py @@ -1019,8 +1019,10 @@ def main(): else: module.fail_json(msg='Failed to update apt cache: %s' % err) cache.open(progress=None) - updated_cache = True - mtimestamp, updated_cache_time = get_updated_cache_time() + mtimestamp, post_cache_update_time = get_updated_cache_time() + if updated_cache_time != post_cache_update_time: + updated_cache = True + updated_cache_time = post_cache_update_time # If there is nothing else to do exit. This will set state as # changed based on if the cache was updated.