summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShachaf92 <shachaf.gold@gmail.com>2020-03-02 00:02:38 +0200
committerGitHub <noreply@github.com>2020-03-02 08:02:38 +1000
commit2e38f80f9e5d6b46c5648e19bcb18b69dbc64762 (patch)
tree3d839143fb8f8f5f85e8385807756d64769f734b
parent64a28641586e384f1c35d5f573735f3e5045db20 (diff)
downloadansible-2e38f80f9e5d6b46c5648e19bcb18b69dbc64762.tar.gz
win_timezone - Allow for _dstoff timezones (#67892)
* win_timezone - Allow for _dstoff timezones * Update win_timezone-Allow-dstoff.yml * Added doc entry for new format Co-authored-by: Jordan Borean <jborean93@gmail.com>
-rw-r--r--changelogs/fragments/win_timezone-Allow-dstoff.yml3
-rw-r--r--lib/ansible/modules/windows/win_timezone.ps110
-rw-r--r--lib/ansible/modules/windows/win_timezone.py5
-rw-r--r--test/integration/targets/win_timezone/tasks/tests.yml11
4 files changed, 21 insertions, 8 deletions
diff --git a/changelogs/fragments/win_timezone-Allow-dstoff.yml b/changelogs/fragments/win_timezone-Allow-dstoff.yml
new file mode 100644
index 0000000000..3d32fd5406
--- /dev/null
+++ b/changelogs/fragments/win_timezone-Allow-dstoff.yml
@@ -0,0 +1,3 @@
+---
+bugfixes:
+ - "win_timezone - Allow for _dstoff timezones"
diff --git a/lib/ansible/modules/windows/win_timezone.ps1 b/lib/ansible/modules/windows/win_timezone.ps1
index 0f609b1584..f46a11c3ad 100644
--- a/lib/ansible/modules/windows/win_timezone.ps1
+++ b/lib/ansible/modules/windows/win_timezone.ps1
@@ -28,18 +28,12 @@ Try {
Exit-Json $result "Timezone '$timezone' is already set on this machine"
} Else {
# Check that timezone is listed as an available timezone to the machine
- $tzList = $(tzutil.exe /l)
+ $tzList = $(tzutil.exe /l).ToLower()
If ($LASTEXITCODE -ne 0) {
Throw "An error occurred when listing the available timezones."
}
- $tzExists = $false
- ForEach ($tz in $tzList) {
- If ( $tz -eq $timezone ) {
- $tzExists = $true
- break
- }
- }
+ $tzExists = $tzList.Contains(($timezone -Replace '_dstoff').ToLower())
if (-not $tzExists) {
Fail-Json $result "The specified timezone: $timezone isn't supported on the machine."
}
diff --git a/lib/ansible/modules/windows/win_timezone.py b/lib/ansible/modules/windows/win_timezone.py
index 6084965794..a3b66c9e56 100644
--- a/lib/ansible/modules/windows/win_timezone.py
+++ b/lib/ansible/modules/windows/win_timezone.py
@@ -20,6 +20,7 @@ options:
description:
- Timezone to set to.
- 'Example: Central Standard Time'
+ - To disable Daylight Saving time, add the suffix C(_dstoff) on timezones that support this.
type: str
required: yes
notes:
@@ -47,6 +48,10 @@ EXAMPLES = r'''
- name: Set timezone to 'Central Standard Time' (GMT-06:00)
win_timezone:
timezone: Central Standard Time
+
+- name: Set timezime to Pacific Standard time and disable Daylight Saving time adjustments
+ win_timezone:
+ timezone: Pacific Standard Time_dstoff
'''
RETURN = r'''
diff --git a/test/integration/targets/win_timezone/tasks/tests.yml b/test/integration/targets/win_timezone/tasks/tests.yml
index 320edc4e49..da5109f7f5 100644
--- a/test/integration/targets/win_timezone/tasks/tests.yml
+++ b/test/integration/targets/win_timezone/tasks/tests.yml
@@ -73,6 +73,17 @@
- central.timezone == 'Central Standard Time'
when: in_check_mode
+- name: Change timezone to dstoff
+ win_timezone:
+ timezone: Eastern Standard Time_dstoff
+ register: dstoff_result
+
+- name: Test dstoff timezone
+ assert:
+ that:
+ - dstoff_result is changed
+ - dstoff_result.timezone == 'Eastern Standard Time_dstoff'
+
- name: Change timezone to GMT+666
win_timezone:
timezone: Dag's Standard Time