From c65f3fdca6be03289319df4689023856d373e396 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Fri, 1 Jun 2018 22:46:07 -0500 Subject: [PATCH] BSD UTC timezone is not always idempotent (#40855) Signed-off-by: Adam Miller --- lib/ansible/modules/system/timezone.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/system/timezone.py b/lib/ansible/modules/system/timezone.py index b7e8b4acab3..d4be8bdb937 100644 --- a/lib/ansible/modules/system/timezone.py +++ b/lib/ansible/modules/system/timezone.py @@ -70,7 +70,6 @@ EXAMPLES = ''' ''' import errno -import filecmp import os import platform import random @@ -711,12 +710,17 @@ class BSDTimezone(Timezone): # but it's intended to avoid useless diff. planned = self.value['name']['planned'] try: - already_planned_state = filecmp.cmp(os.path.join(zoneinfo_dir, planned), localtime_file) + planned_zonefile = os.path.join(zoneinfo_dir, planned) + already_planned_state = filecmp.cmp(planned_zonefile, localtime_file) + except OSError: # Even if reading planned zoneinfo file gives an OSError, don't abort here, # because a bit more detailed check will be done in `set`. already_planned_state = False - if already_planned_state: + # Handle the case where the file comp previously would claim UTC and Etc/UTC + # are the same because they are the same file, but not the same path. This + # breaks idempotent task runs. + if already_planned_state and (planned_zonefile == os.path.realpath(planned_zonefile)): return planned # Strategy 3: