Class: Specinfra::Helper::DetectOs::Redhat

Inherits:
Specinfra::Helper::DetectOs show all
Defined in:
lib/specinfra/helper/detect_os/redhat.rb

Instance Method Summary collapse

Methods inherited from Specinfra::Helper::DetectOs

detect, #initialize, #run_command

Constructor Details

This class inherits a constructor from Specinfra::Helper::DetectOs

Instance Method Details

#detectObject


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/specinfra/helper/detect_os/redhat.rb', line 2

def detect
  # Fedora also has an /etc/redhat-release so the Fedora check must
  # come before the RedHat check
  if run_command('ls /etc/fedora-release').success?
    line = run_command('cat /etc/redhat-release').stdout
    if line =~ /release (\d[\d]*)/
      release = $1
    end
    { :family => 'fedora', :release => release }
  elsif run_command('ls /etc/redhat-release').success?
    line = run_command('cat /etc/redhat-release').stdout
    if line =~ /release (\d[\d.]*)/
      release = $1
    end

    { :family => 'redhat', :release => release }
  elsif run_command('ls /etc/system-release').success?
    { :family => 'redhat', :release => nil  } # Amazon Linux
  end
end