Sha256: f7f7c8d8d1516452d2d703374e284dd934b93ff18c989ca32c1cc0f3657be797
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
# frozen_string_literal: true module Facter module Resolvers class RedHatRelease < BaseResolver # :name # :version # :codename init_resolver class << self private def post_resolve(fact_name) @fact_list.fetch(fact_name) { read_redhat_release(fact_name) } end def read_redhat_release(fact_name) output = Util::FileHelper.safe_read('/etc/redhat-release', nil) return @fact_list[fact_name] = nil if output.nil? build_fact_list(output) @fact_list[fact_name] end def build_fact_list(output) output_strings = output.split('release') output_strings.map!(&:strip) version_codename = output_strings[1].split(' ') @fact_list[:name] = name(output_strings[0]) @fact_list[:version] = version_codename[0]&.strip codename = version_codename[1]&.strip @fact_list[:codename] = codename ? codename.gsub(/[()]/, '') : nil @fact_list[:identifier] = identifier(@fact_list[:name]) end def name(name) name.strip.split(' ')[0..1].join end def identifier(name) identifier = name.strip.downcase identifier = 'rhel' if @fact_list[:name].strip.casecmp('Red Hat Enterprise Linux') identifier end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
facter-4.0.46 | lib/facter/resolvers/redhat_release_resolver.rb |