From f7d8a527ada7cbeae35c4f75e8f5ae1b8c5502a0 Mon Sep 17 00:00:00 2001 From: Mike Riddle Date: Mon, 11 Dec 2023 11:00:57 -0500 Subject: [PATCH] Accounting for if '/usr/share/zoneinfo/#{Facter.value('timezone')}' doesn't exist --- lib/facter/timezone_file.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/facter/timezone_file.rb b/lib/facter/timezone_file.rb index e45bd26..7ed089c 100644 --- a/lib/facter/timezone_file.rb +++ b/lib/facter/timezone_file.rb @@ -5,7 +5,14 @@ Facter.add("timezone_file") do setcode do # If /etc/localtime doesn't exist, use the appropriate file in /usr/share/zoneinfo - timezone_file = File.exist?('/etc/localtime') ? '/etc/localtime' : "/usr/share/zoneinfo/#{Facter.value('timezone')}" + timezone_file = '' + if File.exist?('/etc/localtime') + timezone_file = '/etc/localtime' + elsif File.exist?("/usr/share/zoneinfo/#{Facter.value('timezone')}") + timezone_file = "/usr/share/zoneinfo/#{Facter.value('timezone')}" + else + timezone_file = '/usr/share/zoneinfo/UTC' + end timezone_file end end \ No newline at end of file