module ForemanMaintain::Concerns::OsFacts
Constants
- FALLBACK_OS_RELEASE_FILE
- OS_RELEASE_FILE
Public Instance Methods
debian?()
click to toggle source
# File lib/foreman_maintain/concerns/os_facts.rb, line 53 def debian? File.exist?('/etc/debian_version') end
el7?()
click to toggle source
# File lib/foreman_maintain/concerns/os_facts.rb, line 57 def el7? el_major_version == 7 end
el8?()
click to toggle source
# File lib/foreman_maintain/concerns/os_facts.rb, line 61 def el8? el_major_version == 8 end
el?()
click to toggle source
# File lib/foreman_maintain/concerns/os_facts.rb, line 49 def el? File.exist?('/etc/redhat-release') end
el_major_version()
click to toggle source
# File lib/foreman_maintain/concerns/os_facts.rb, line 65 def el_major_version return os_version_id.to_i if el? end
facts()
click to toggle source
# File lib/foreman_maintain/concerns/os_facts.rb, line 19 def facts unless defined?(@facts) @facts = {} regex = /^(["'])(.*)(\1)$/ File.open(os_release_file) do |file| file.readlines.each do |line| line.strip! # drop any whitespace, including newlines from start and end of the line next if line.start_with?('#') # ignore comments # split at most into 2 items, if the value ever contains an = key, value = line.split('=', 2) next unless key && value @facts[key] = value.gsub(regex, '\2').delete('\\') end end end @facts end
os_id()
click to toggle source
# File lib/foreman_maintain/concerns/os_facts.rb, line 41 def os_id facts.fetch('ID') end
os_id_like_list()
click to toggle source
# File lib/foreman_maintain/concerns/os_facts.rb, line 45 def os_id_like_list facts.fetch('ID_LIKE', '').split end
os_release_file()
click to toggle source
# File lib/foreman_maintain/concerns/os_facts.rb, line 7 def os_release_file if File.file?(OS_RELEASE_FILE) return OS_RELEASE_FILE elsif File.file?(FALLBACK_OS_RELEASE_FILE) return FALLBACK_OS_RELEASE_FILE else puts "The #{OS_RELEASE_FILE} and #{FALLBACK_OS_RELEASE_FILE} files are missing! "\ "Can't continue the execution without Operating System's facts!" exit 1 end end
os_version_id()
click to toggle source
# File lib/foreman_maintain/concerns/os_facts.rb, line 37 def os_version_id facts.fetch('VERSION_ID') end