summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-08-18 15:00:42 -0700
committerTim Smith <tsmith84@gmail.com>2020-08-18 15:00:42 -0700
commit97f8bc54bb76edbac93d7c53252f52866c648dbf (patch)
tree8d65e64e7649e6d830eb1e92a56ff9f9841d73c8 /lib/chef
parent2a003da0ad960c7cb6784174fd111ebf69fd427e (diff)
downloadchef-97f8bc54bb76edbac93d7c53252f52866c648dbf.tar.gz
Make sure windows can still take case insensitive values
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/resource/timezone.rb77
1 files changed, 42 insertions, 35 deletions
diff --git a/lib/chef/resource/timezone.rb b/lib/chef/resource/timezone.rb
index 5bcd6c0458..97aa738af9 100644
--- a/lib/chef/resource/timezone.rb
+++ b/lib/chef/resource/timezone.rb
@@ -122,43 +122,50 @@ class Chef
action :set do
description "Set the timezone."
- converge_if_changed(:timezone) do
- # Modern SUSE, Amazon, Fedora, RHEL, Ubuntu & Debian
- if systemd?
- # make sure we have the tzdata files
- package suse? ? "timezone" : "tzdata"
-
- shell_out!(["/usr/bin/timedatectl", "--no-ask-password", "set-timezone", new_resource.timezone])
- else
- case node["platform_family"]
- # Old version of RHEL < 7 and Amazon 201X
- when "rhel", "amazon"
+ # we have to check windows first since the value isn't case sensitive here
+ if windows?
+ unless current_windows_tz.casecmp?(new_resource.timezone)
+ converge_by("setting timezone to '#{new_resource.timezone}'") do
+ shell_out!(["tzutil", "/s", new_resource.timezone])
+ end
+ end
+ else # linux / macos
+ converge_if_changed(:timezone) do
+ # Modern SUSE, Amazon, Fedora, RHEL, Ubuntu & Debian
+ if systemd?
# make sure we have the tzdata files
- package "tzdata"
-
- file "/etc/sysconfig/clock" do
- owner "root"
- group "root"
- mode "0644"
- action :create
- content %{ZONE="#{new_resource.timezone}"\nUTC="true"\n}
- end
-
- execute "tzdata-update" do
- command "/usr/sbin/tzdata-update"
- action :nothing
- only_if { ::File.executable?("/usr/sbin/tzdata-update") }
- subscribes :run, "file[/etc/sysconfig/clock]", :immediately
- end
-
- link "/etc/localtime" do
- to "/usr/share/zoneinfo/#{new_resource.timezone}"
- not_if { ::File.executable?("/usr/sbin/tzdata-update") }
+ package suse? ? "timezone" : "tzdata"
+
+ shell_out!(["/usr/bin/timedatectl", "--no-ask-password", "set-timezone", new_resource.timezone])
+ else
+ case node["platform_family"]
+ # Old version of RHEL < 7 and Amazon 201X
+ when "rhel", "amazon"
+ # make sure we have the tzdata files
+ package "tzdata"
+
+ file "/etc/sysconfig/clock" do
+ owner "root"
+ group "root"
+ mode "0644"
+ action :create
+ content %{ZONE="#{new_resource.timezone}"\nUTC="true"\n}
+ end
+
+ execute "tzdata-update" do
+ command "/usr/sbin/tzdata-update"
+ action :nothing
+ only_if { ::File.executable?("/usr/sbin/tzdata-update") }
+ subscribes :run, "file[/etc/sysconfig/clock]", :immediately
+ end
+
+ link "/etc/localtime" do
+ to "/usr/share/zoneinfo/#{new_resource.timezone}"
+ not_if { ::File.executable?("/usr/sbin/tzdata-update") }
+ end
+ when "mac_os_x"
+ shell_out!(["sudo", "systemsetup", "-settimezone", new_resource.timezone])
end
- when "mac_os_x"
- shell_out!(["sudo", "systemsetup", "-settimezone", new_resource.timezone])
- when "windows"
- shell_out!(["tzutil", "/s", new_resource.timezone])
end
end
end