Skip to content

Commit

Permalink
remove usage of $::lsbmajdistrelease fact
Browse files Browse the repository at this point in the history
Instead use $::operatingsystemmajrelease as this fact is not dependant on
redhat-lsb being present on the system.
  • Loading branch information
Joshua Hoblitt committed Sep 21, 2013
1 parent cd410c3 commit 2e4a9d4
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 8 deletions.
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ require 'puppet-lint/tasks/puppet-lint'
PuppetSyntax.exclude_paths = ['spec/fixtures/**/*']
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_variable_scope')
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.ignore_paths = ['pkg/**/*.pp', 'spec/**/*.pp', 'tests/**/*.pp']

task :default => [
Expand Down
8 changes: 6 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

case $::osfamily {
redhat: {
case $::lsbmajdistrelease {
case $::operatingsystemmajrelease {
# the epel packages change uid/gids + install paths between 5 & 6
5: {
$gmond_service_config = '/etc/gmond.conf'
Expand All @@ -37,13 +37,17 @@
}
# fedora is also part of $::osfamily = redhat so we shouldn't default
# to failing on el7.x +
6, default: {
# match 7 .. 99
6, /^([7-9]|[1-9][0-9])$/: {
$gmond_service_config = '/etc/ganglia/gmond.conf'
$gmond_service_erb = 'ganglia/gmond.conf.el6.erb'

$gmetad_service_config = '/etc/ganglia/gmetad.conf'
$gmetad_service_erb = 'ganglia/gmetad.conf.el6.erb'
}
default: {
fail("Module ${module_name} is not supported on operatingsystemmajrelease ${::operatingsystemmajrelease}")
}
}
}
default: {
Expand Down
3 changes: 1 addition & 2 deletions spec/classes/gmetad_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
require 'spec_helper'

describe 'ganglia::gmetad' do
let(:title) { 'redhat' }
let(:facts) { {:osfamily=> 'RedHat'} }
let(:facts) {{ :osfamily => 'RedHat', :operatingsystemmajrelease => 6 }}

context 'with clusters' do
clusters = [
Expand Down
3 changes: 1 addition & 2 deletions spec/classes/gmond_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
require 'spec_helper'

describe 'ganglia::gmond' do
let(:title) { 'redhat' }
let(:facts) { {:osfamily=> 'RedHat', :lsbmajordistrelease => 6} }
let(:facts) {{ :osfamily => 'RedHat', :operatingsystemmajrelease => 6 }}

context 'with lots of params' do
udp_recv_channel = [
Expand Down
50 changes: 50 additions & 0 deletions spec/classes/params_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
require 'spec_helper'

describe 'ganglia::params', :type => :class do

describe 'for osfamily RedHat' do
let(:facts) {{ :osfamily => 'RedHat' }}

describe 'el5.x' do
before { facts[:operatingsystemmajrelease] = '5' }

it { should include_class('ganglia::params') }
end

describe 'el6.x' do
before { facts[:operatingsystemmajrelease] = '6' }

it { should include_class('ganglia::params') }
end

describe 'el7.x+/fedora' do
before { facts[:operatingsystemmajrelease] = '7' }

it { should include_class('ganglia::params') }
end

describe 'el4.x' do
before { facts[:operatingsystemmajrelease] = '4' }

it 'should fail' do
expect { should include_class('ganglia::params') }.
to raise_error(Puppet::Error, /not supported on operatingsystemmajrelease/)
end
end
end

describe 'unsupported osfamily' do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Debian',
}
end

it 'should fail' do
expect { should include_class('ganglia::params') }.
to raise_error(Puppet::Error, /not supported on Debian/)
end
end

end
3 changes: 1 addition & 2 deletions spec/classes/web_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
require 'spec_helper'

describe 'ganglia::web' do
let(:title) { 'redhat' }
let(:facts) { {:osfamily=> 'RedHat'} }
let(:facts) {{ :osfamily => 'RedHat', :operatingsystemmajrelease => 6 }}

context 'with out params' do
let(:params) { { } }
Expand Down

0 comments on commit 2e4a9d4

Please sign in to comment.