Sha256: 991b3e1eff0b2d17aa89e533e685d69768899e441e51a9c5cc3286f91598540f

Contents?: true

Size: 1.71 KB

Versions: 3

Compression:

Stored size: 1.71 KB

Contents

require 'facter/lsb'

Facter.add(:operatingsystem) do
    confine :kernel => :sunos
    setcode do "Solaris" end
end

Facter.add(:operatingsystem) do
    confine :kernel => :linux
    setcode do
        if Facter.value(:lsbdistid) == "Ubuntu"
           "Ubuntu"
        elsif FileTest.exists?("/etc/debian_version")
            "Debian"
        elsif FileTest.exists?("/etc/gentoo-release")
            "Gentoo"
        elsif FileTest.exists?("/etc/fedora-release")
            "Fedora"
        elsif FileTest.exists?("/etc/mandriva-release")
            "Mandriva"
        elsif FileTest.exists?("/etc/mandrake-release")
            "Mandrake"
        elsif FileTest.exists?("/etc/arch-release")
            "Archlinux"
        elsif FileTest.exists?("/etc/enterprise-release")
            if FileTest.exists?("/etc/ovs-release")
                "OVS"
            else
                "OEL"
            end
        elsif FileTest.exists?("/etc/arch-release")
            "Arch"
        elsif FileTest.exists?("/etc/redhat-release")
            txt = File.read("/etc/redhat-release")
            if txt =~ /centos/i
                "CentOS"
            else
                "RedHat"
            end
        elsif FileTest.exists?("/etc/SuSE-release")
            txt = File.read("/etc/SuSE-release")
            if txt =~ /^SUSE LINUX Enterprise Server/i
                "SLES"
            elsif txt =~ /^SUSE LINUX Enterprise Desktop/i
                "SLED"
            elsif txt =~ /^openSUSE/i
                "OpenSuSE"
            else
                "SuSE"
            end
        end
    end
end

Facter.add(:operatingsystem) do
    # Default to just returning the kernel as the operating system
    setcode do Facter[:kernel].value end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facter-1.5.7 lib/facter/operatingsystem.rb
facter-1.5.5 lib/facter/operatingsystem.rb
facter-1.5.6 lib/facter/operatingsystem.rb