Skip to content

Commit

Permalink
Move all OS-dependent config to params.pp
Browse files Browse the repository at this point in the history
This also treats the entire RedHat osfamily (except Fedora) as EL.
  • Loading branch information
ekohl committed Nov 12, 2014
1 parent 1bd26ad commit fb93e28
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 31 deletions.
11 changes: 1 addition & 10 deletions manifests/install.pp
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
# Katello Install
class katello::install {
if ($::osfamily == 'RedHat' and $::operatingsystem != 'Fedora'){
$os = 'RHEL'
} else {
$os = 'Fedora'
}
$rubygem = $os ? {
'RHEL' => 'ruby193-rubygem-katello',
'Fedora' => 'rubygem-katello'
}
package{['katello', $rubygem]:
package { $katello::package_names:
ensure => installed,
}
}
24 changes: 18 additions & 6 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# Katello Default Params
class katello::params {

if ($::osfamily == 'RedHat' and $::operatingsystem != 'Fedora'){
$scl_prefix = 'ruby193-'
$scl_root = '/opt/rh/ruby193/root'
} else {
$scl_prefix = ''
$scl_root = ''
case $::osfamily {
'RedHat': {
case $::operatingsystem {
'Fedora': {
$scl_prefix = ''
$scl_root = ''
}
default: {
$scl_prefix = 'ruby193-'
$scl_root = '/opt/rh/ruby193/root'
}
}

$package_names = ['katello', "${scl_prefix}rubygem-katello"]
}
default: {
fail("${::hostname}: This module does not support osfamily ${::osfamily}")
}
}

$rhsm_url = '/rhsm'
Expand Down
103 changes: 88 additions & 15 deletions spec/classes/katello_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
require 'spec_helper'

describe 'katello' do
context 'on redhat' do
let(:params) do
{:user => 'foreman'}
end
context 'on redhat' do
let :facts do
{
:concat_basedir => '/tmp',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.4',
:operatingsystemmajrelease => '6.4',
:osfamily => 'RedHat',
:concat_basedir => '/tmp',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.5',
:operatingsystemmajrelease => '6',
:osfamily => 'RedHat',
}
end

Expand All @@ -23,14 +20,55 @@
it { should contain_class('katello::config') }
it { should contain_class('katello::service') }
end
context 'on oel' do

context 'on centos' do
let :facts do
{
:concat_basedir => '/tmp',
:operatingsystem => 'CentOS',
:operatingsystemrelease => '6.5',
:operatingsystemmajrelease => '6',
:osfamily => 'RedHat',
}
end

let(:pre_condition) do
['include foreman','include certs']
end

it { should contain_class('katello::install') }
it { should contain_class('katello::config') }
it { should contain_class('katello::service') }
end

context 'on oel' do
let :facts do
{
:concat_basedir => '/tmp',
:operatingsystem => 'OracleLinux',
:operatingsystemrelease => '6.5',
:operatingsystemmajrelease => '6',
:osfamily => 'RedHat',
}
end

let(:pre_condition) do
['include foreman','include certs']
end

it { should contain_class('katello::install') }
it { should contain_class('katello::config') }
it { should contain_class('katello::service') }
end

context 'on fedora' do
let :facts do
{
:concat_basedir => '/tmp',
:operatingsystem => 'OracleLinux',
:operatingsystemrelease => '6.5',
:operatingsystemmajrelease => '6.5',
:osfamily => 'RedHat',
:concat_basedir => '/tmp',
:operatingsystem => 'Fedora',
:operatingsystemrelease => '20',
:operatingsystemmajrelease => '20',
:osfamily => 'RedHat',
}
end

Expand All @@ -43,4 +81,39 @@
it { should contain_class('katello::service') }
end

context 'on oel' do
let :facts do
{
:concat_basedir => '/tmp',
:operatingsystem => 'OracleLinux',
:operatingsystemrelease => '6.5',
:operatingsystemmajrelease => '6',
:osfamily => 'RedHat',
}
end

let(:pre_condition) do
['include foreman','include certs']
end

it { should contain_class('katello::install') }
it { should contain_class('katello::config') }
it { should contain_class('katello::service') }
end

context 'on unsupported osfamily' do
let :facts do
{
:concat_basedir => '/tmp',
:hostname => 'localhost',
:operatingsystem => 'UNSUPPORTED OPERATINGSYSTEM',
:operatingsystemmajrelease => '1',
:operatingsystemrelease => '1',
:osfamily => 'UNSUPPORTED OSFAMILY',
}
end

it { expect { should contain_class('katello') }.to raise_error(Puppet::Error, /#{facts[:hostname]}: This module does not support osfamily #{facts[:osfamily]}/) }
end

end

0 comments on commit fb93e28

Please sign in to comment.