From a8c823e81370bc2690e453538cd97efeda70e0f2 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 25 Apr 2018 16:30:06 -0400 Subject: [PATCH] Ensure timezone tests reset system timezone to original value (#39326) (cherry picked from commit fda67bae50c3384f8656b5c013bfed5cb360997d) --- .../targets/timezone/tasks/main.yml | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/test/integration/targets/timezone/tasks/main.yml b/test/integration/targets/timezone/tasks/main.yml index 63b5edf1e73..d0b396d72cf 100644 --- a/test/integration/targets/timezone/tasks/main.yml +++ b/test/integration/targets/timezone/tasks/main.yml @@ -1,15 +1,21 @@ -- name: set timezone to Etc/UTC +- name: Set timezone to Etc/UTC timezone: name: Etc/UTC + register: original_timezone -- name: set timezone to Australia/Brisbane - timezone: - name: Australia/Brisbane - register: timezone_set +- block: + - name: Set timezone to Australia/Brisbane + timezone: + name: Australia/Brisbane + register: timezone_set -- name: ensure timezone changed - assert: - that: - - timezone_set.changed - - timezone_set.diff.after.name == 'Australia/Brisbane' - - timezone_set.diff.before.name == 'Etc/UTC' + - name: Ensure timezone changed + assert: + that: + - timezone_set is changed + - timezone_set.diff.after.name == 'Australia/Brisbane' + - timezone_set.diff.before.name == 'Etc/UTC' + always: + - name: Restore original system timezone - {{ original_timezone.diff.before.name }} + timezone: + name: "{{ original_timezone.diff.before.name }}"