Ensure timezone tests reset system timezone to original value (#39326)

This commit is contained in:
Sam Doran 2018-04-25 16:30:06 -04:00 committed by GitHub
parent dd735b2122
commit fda67bae50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,15 +1,21 @@
- name: set timezone to Etc/UTC - name: Set timezone to Etc/UTC
timezone: timezone:
name: Etc/UTC name: Etc/UTC
register: original_timezone
- name: set timezone to Australia/Brisbane - block:
timezone: - name: Set timezone to Australia/Brisbane
name: Australia/Brisbane timezone:
register: timezone_set name: Australia/Brisbane
register: timezone_set
- name: ensure timezone changed - name: Ensure timezone changed
assert: assert:
that: that:
- timezone_set.changed - timezone_set is changed
- timezone_set.diff.after.name == 'Australia/Brisbane' - timezone_set.diff.after.name == 'Australia/Brisbane'
- timezone_set.diff.before.name == 'Etc/UTC' - 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 }}"