class Chef::Resource::Timezone
Public Instance Methods
Source
# File lib/chef/resource/timezone.rb, line 62 def current_macos_tz tz_shellout = shell_out!(["systemsetup", "-gettimezone"]) if /You need administrator access/.match?(tz_shellout.stdout) raise "The timezone resource requires administrative privileges to run on macOS hosts!" else /Time Zone: (.*)/.match(tz_shellout.stdout)[1] end end
detect the current TZ on darwin hosts
@since 14.7 @return [String] TZ database value
Source
# File lib/chef/resource/timezone.rb, line 98 def current_rhel_tz return nil unless ::File.exist?("/etc/sysconfig/clock") # https://rubular.com/r/aoj01L3bKBM7wh /ZONE="(.*)"/.match(::File.read("/etc/sysconfig/clock"))[1] end
detect the current timezone on non-systemd RHEL-ish hosts
@since 16.5 @return [String] timezone id
Source
# File lib/chef/resource/timezone.rb, line 86 def current_systemd_tz tz_shellout = shell_out(["/usr/bin/timedatectl", "status"]) raise "There was an error running the timedatectl command" if tz_shellout.error? # https://rubular.com/r/eV68MX9XXbyG4k /Time zone: (.*) \(.*/.match(tz_shellout.stdout)[1] end
detect the current timezone on systemd hosts
@since 16.5 @return [String] timezone id
Source
# File lib/chef/resource/timezone.rb, line 75 def current_windows_tz tz_shellout = shell_out("tzutil /g") raise "There was an error running the tzutil command" if tz_shellout.error? tz_shellout.stdout.strip end
detect the current timezone on windows hosts
@since 14.7 @return [String] timezone id