summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusername-is-already-taken2 <digitalgaz@hotmail.com>2018-10-29 17:04:30 +0000
committerTim Smith <tsmith@chef.io>2019-01-16 16:52:55 -0800
commit7421245cd6abd22adcc9c4decb82700a5f2cb9ee (patch)
tree580a197a4db5634483d6d3a6b46d941c2a00c81c
parentd670c806169ce70799965f4a76254c5306987cb0 (diff)
downloadchef-7421245cd6abd22adcc9c4decb82700a5f2cb9ee.tar.gz
Added windows support for the timezone resource
Signed-off-by: username-is-already-taken2 <digitalgaz@hotmail.com>
-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