summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusername-is-already-taken2 <digitalgaz@hotmail.com>2018-10-29 17:04:30 +0000
committerusername-is-already-taken2 <digitalgaz@hotmail.com>2018-10-29 17:06:39 +0000
commit4422560c0f4f6c69775ba9c035f4ac86eb56b8db (patch)
tree7ee5aaf00d118b995e21f744447348f7a2a6f8f4
parentfc44abc83b494ba7c72c74f27847d1a5a9384add (diff)
downloadchef-4422560c0f4f6c69775ba9c035f4ac86eb56b8db.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 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