summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/resource/timezone.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/chef/resource/timezone.rb b/lib/chef/resource/timezone.rb
index da3cb70bb9..25d2c2cd73 100644
--- a/lib/chef/resource/timezone.rb
+++ b/lib/chef/resource/timezone.rb
@@ -95,12 +95,18 @@ class Chef
shell_out!("sudo systemsetup -settimezone #{new_resource.timezone}")
end
end
+ when "windows"
+ unless current_windows_tz.casecmp?(new_resource.timezone)
+ converge_by("set timezone to \"#{new_resource.timezone}\"") do
+ shell_out!("tzutil /s \"#{new_resource.timezone}\"")
+ end
+ end
end
end
end
action_class do
- # detect the current TZ on darwin hosts
+ # detect the current TZ on darwin hosts & windows hosts
#
# @since 14.7
# @return [String] TZ database value
@@ -112,6 +118,14 @@ class Chef
/Time Zone: (.*)/.match(tz_shellout.stdout)[1]
end
end
+ def current_windows_tz
+ tz_shellout = shell_out!("tzutil /g")
+ if /is not recognized as an internal/.match?(tz_shellout.stderr)
+ raise "The timezone resource requires tzutil to run on windows hosts!"
+ else
+ tz_shellout.stdout.strip
+ end
+ end
end
end
end