From 2e4a9d4b52f16d2e5874ad2f288dbacc7138cd9c Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Sat, 21 Sep 2013 14:58:53 -0700 Subject: [PATCH] remove usage of $::lsbmajdistrelease fact Instead use $::operatingsystemmajrelease as this fact is not dependant on redhat-lsb being present on the system. --- Rakefile | 1 + manifests/params.pp | 8 ++++-- spec/classes/gmetad_spec.rb | 3 +-- spec/classes/gmond_spec.rb | 3 +-- spec/classes/params_spec.rb | 50 +++++++++++++++++++++++++++++++++++++ spec/classes/web_spec.rb | 3 +-- 6 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 spec/classes/params_spec.rb diff --git a/Rakefile b/Rakefile index 07f9b50..593768f 100644 --- a/Rakefile +++ b/Rakefile @@ -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 => [ diff --git a/manifests/params.pp b/manifests/params.pp index 0a4f9ee..76be5d4 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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' @@ -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: { diff --git a/spec/classes/gmetad_spec.rb b/spec/classes/gmetad_spec.rb index 8aef6f7..62d8dea 100644 --- a/spec/classes/gmetad_spec.rb +++ b/spec/classes/gmetad_spec.rb @@ -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 = [ diff --git a/spec/classes/gmond_spec.rb b/spec/classes/gmond_spec.rb index b681568..1d1ce83 100644 --- a/spec/classes/gmond_spec.rb +++ b/spec/classes/gmond_spec.rb @@ -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 = [ diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb new file mode 100644 index 0000000..a15a975 --- /dev/null +++ b/spec/classes/params_spec.rb @@ -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 diff --git a/spec/classes/web_spec.rb b/spec/classes/web_spec.rb index 4c6cd71..c67aa4e 100644 --- a/spec/classes/web_spec.rb +++ b/spec/classes/web_spec.rb @@ -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) { { } }