class Facter::Operatingsystem::Linux

Public Instance Methods

collect_lsb_information() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 221
def collect_lsb_information
  @lsb_data ||= Facter::Core::Execution.exec("lsb_release -cidvr 2>/dev/null")
  @data_hash = {}

  if @lsb_data && @data_hash.empty?
    @lsb_data.split("\n").each do |element|
      lsbvar, value = element.split("\t")
      lsbvar.gsub!(":", "")
      @data_hash["#{lsbvar}"] = value
    end
  end

  @data_hash unless @data_hash.empty?
end
get_lsb_facts_hash() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 189
def get_lsb_facts_hash
  lsb_hash = {}
  if lsbdistcodename = get_lsbdistcodename
    lsb_hash["distcodename"] = lsbdistcodename
  end

  if lsbdistid = get_lsbdistid
    lsb_hash["distid"] = lsbdistid
  end

  if lsbdistdescription = get_lsbdistdescription
    lsb_hash["distdescription"] = lsbdistdescription
  end

  if lsbrelease = get_lsbrelease
    lsb_hash["release"] = lsbrelease
  end

  if lsbdistrelease = get_lsbdistrelease
    lsb_hash["distrelease"] = lsbdistrelease
  end

  if lsbmajdistrelease = get_lsbmajdistrelease
    lsb_hash["majdistrelease"]  = lsbmajdistrelease
  end

  if lsbminordistrelease = get_lsbminordistrelease
    lsb_hash["minordistrelease"]  = lsbminordistrelease
  end
  lsb_hash
end
get_lsbdistcodename() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 119
def get_lsbdistcodename
  if (lsb_data = collect_lsb_information)
    lsb_data["Codename"]
  end
end
get_lsbdistdescription() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 131
def get_lsbdistdescription
  if (lsb_data = collect_lsb_information)
    lsb_data["Description"].sub(/^"(.*)"$/,'\1')
  end
end
get_lsbdistid() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 125
def get_lsbdistid
  if (lsb_data = collect_lsb_information)
    lsb_data["Distributor ID"]
  end
end
get_lsbdistrelease() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 143
def get_lsbdistrelease
  if (lsb_data = collect_lsb_information)
    lsb_data["Release"]
  end
end
get_lsbmajdistrelease() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 149
def get_lsbmajdistrelease
  lsbdistrelease = get_lsbdistrelease
  if get_operatingsystem == "Ubuntu"
    if (lsbreleasemajor = lsbdistrelease.split("."))
      if lsbreleasemajor.length >= 2
        result = "#{lsbreleasemajor[0]}.#{lsbreleasemajor[1]}"
      else
        result = lsbreleasemajor
      end
    end
  else
    if /(\d*)\./i =~ lsbdistrelease
      result = $1
    else
      result = lsbdistrelease
    end
  end
  result
end
get_lsbminordistrelease() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 169
def get_lsbminordistrelease
  lsbdistrelease = get_lsbdistrelease
  if get_operatingsystem == "Ubuntu"
    mdata = /(\d+).(\d+).(\d+)/i.match(lsbdistrelease)
    if mdata == nil
      result = nil
    else
      result = mdata[3]
    end
  else
    mdata = /(\d+).(\d+)/i.match(lsbdistrelease)
    if mdata == nil
      result = nil
    else
      result = mdata[2]
    end
  end
  result
end
get_lsbrelease() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 137
def get_lsbrelease
  if (lsb_data = collect_lsb_information)
    lsb_data["LSB Version"]
  end
end
get_operatingsystem() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 8
def get_operatingsystem
  if Facter.value(:kernel) == "GNU/kFreeBSD"
    "GNU/kFreeBSD"
  elsif lsbdistid = get_lsbdistid
    if lsbdistid == "Ubuntu"
      @operatingsystem ||= "Ubuntu"
    elsif lsbdistid == "LinuxMint"
      @operatingsystem ||= "LinuxMint"
    else
      @operatingsystem ||= get_operatingsystem_with_release_files
    end
  else
    @operatingsystem ||= get_operatingsystem_with_release_files
  end
end
get_operatingsystemmajorrelease() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 79
def get_operatingsystemmajorrelease
  if operatingsystemrelease = get_operatingsystemrelease
    if get_operatingsystem == "Ubuntu"
      if (releasemajor = operatingsystemrelease.split("."))
        if releasemajor.length >= 2
          "#{releasemajor[0]}.#{releasemajor[1]}"
        else
          releasemajor[0]
        end
      end
    else
      if (releasemajor = operatingsystemrelease.split(".")[0])
        releasemajor
      end
    end
  end
end
get_operatingsystemminorrelease() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 97
def get_operatingsystemminorrelease
  if operatingsystemrelease = get_operatingsystemrelease
    if get_operatingsystem == "Ubuntu"
      if (releaseminor = operatingsystemrelease.split(".")[2])
        releaseminor
      end
    else
      if (releaseminor = operatingsystemrelease.split(".")[1])
        if releaseminor.include? "-"
          releaseminor.split("-")[0]
        else
          releaseminor
        end
      end
    end
  end
end
get_operatingsystemrelease() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 43
def get_operatingsystemrelease
  case get_operatingsystem
  when "Alpine"
    get_alpine_release_with_release_file
  when "Amazon"
    get_amazon_release_with_lsb
  when "AristaEOS"
    get_arista_release_with_release_file
  when "BlueWhite64"
    get_bluewhite_release_with_release_file
  when "CentOS", "RedHat", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM",
       "XenServer", "Fedora", "MeeGo", "OracleLinux", "OEL", "oel", "OVS", "ovs"
    get_redhatish_release_with_release_file
  when "Debian"
    get_debian_release_with_release_file
  when "LinuxMint"
    get_linux_mint_release_with_release_file
  when "Mageia"
    get_mageia_release_with_release_file
  when "OpenWrt"
    get_openwrt_release_with_release_file
  when "Slackware"
    get_slackware_release_with_release_file
  when "Slamd64"
    get_slamd64_release_with_release_file
 when "SLES", "SLED", "OpenSuSE"
    get_suse_release_with_release_file
  when "Ubuntu"
    get_ubuntu_release_with_release_file
  when "VMwareESX"
    get_vmwareESX_release_with_release_file
  else
    Facter.value(:kernelrelease)
  end
end
get_osfamily() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 24
def get_osfamily
  case get_operatingsystem
  when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "OracleLinux", "OVS", "OEL", "Amazon", "XenServer"
    "RedHat"
  when "LinuxMint", "Ubuntu", "Debian"
    "Debian"
  when "SLES", "SLED", "OpenSuSE", "SuSE"
    "Suse"
  when "Gentoo"
    "Gentoo"
  when "Archlinux", "Manjarolinux"
    "Archlinux"
  when "Mageia", "Mandriva", "Mandrake"
    "Mandrake"
  else
    Facter.value("kernel")
  end
end
has_lsb?() click to toggle source
# File lib/facter/operatingsystem/linux.rb, line 115
def has_lsb?
  true
end