summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-01-16 16:54:47 -0800
committerTim Smith <tsmith@chef.io>2019-01-16 16:54:47 -0800
commit5c10d56ebf7d20631b58cfe1db2572d8a30f92ca (patch)
tree914de73e7a32bbf2f09d2c5daf70ae0a94aab59e
parent01f2649c9496e51162b6e60d4813cd6d1781e5f8 (diff)
downloadchef-5c10d56ebf7d20631b58cfe1db2572d8a30f92ca.tar.gz
Cherry pick the remaining timezone windows changes
These couldn't be cherry picked in git due to a merge commit. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/timezone.rb18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/chef/resource/timezone.rb b/lib/chef/resource/timezone.rb
index 0898107781..4be52f305a 100644
--- a/lib/chef/resource/timezone.rb
+++ b/lib/chef/resource/timezone.rb
@@ -98,7 +98,7 @@ class Chef
end
when "windows"
unless current_windows_tz.casecmp?(new_resource.timezone)
- converge_by("set timezone to \"#{new_resource.timezone}\"") do
+ converge_by("setting timezone to \"#{new_resource.timezone}\"") do
shell_out!("tzutil /s \"#{new_resource.timezone}\"")
end
end
@@ -107,7 +107,7 @@ class Chef
end
action_class do
- # detect the current TZ on darwin hosts & windows hosts
+ # detect the current TZ on darwin hosts
#
# @since 14.7
# @return [String] TZ database value
@@ -119,13 +119,15 @@ class Chef
/Time Zone: (.*)/.match(tz_shellout.stdout)[1]
end
end
+
+ # detect the current timezone on windows hosts
+ #
+ # @since 14.9
+ # @return [String] timezone id
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
+ tz_shellout = shell_out("tzutil /g")
+ raise "There was an error running the tzutil command" if tz_shellout.exitstatus == 1
+ tz_shellout.stdout.strip
end
end
end