summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 d73d5b87ff..0898107781 100644
--- a/lib/chef/resource/timezone.rb
+++ b/lib/chef/resource/timezone.rb
@@ -96,12 +96,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
@@ -113,6 +119,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