Skip to content

Commit

Permalink
win_timezone - ensure original timezone is restored at end of test
Browse files Browse the repository at this point in the history
  • Loading branch information
jborean93 committed Nov 27, 2024
1 parent ebdfa63 commit 206199f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions tests/integration/targets/win_timezone/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
- name: Determine if server has tzutil.exe installed
ansible.windows.win_command: tzutil.exe /l
register: tzutil
ignore_errors: yes

- name: Only run tests if tzutil.exe is installed
when: tzutil.rc == 0
block:
- name: get current timezone
win_command: tzutil.exe /g
register: original_timezone
changed_when: false

- block:
- name: Test in normal mode
import_tasks: tests.yml
vars:
Expand All @@ -17,3 +14,8 @@
vars:
in_check_mode: yes
check_mode: yes

always:
- name: reset timezone back to defaults
win_timezone:
timezone: "{{ original_timezone.stdout | trim }}"
2 changes: 1 addition & 1 deletion tests/integration/targets/win_timezone/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@

- name: Restore original timezone
win_timezone:
timezone: '{{ original.timezone }}'
timezone: '{{ original.previous_timezone }}'

0 comments on commit 206199f

Please sign in to comment.