diff --git a/manifests/install.pp b/manifests/install.pp index 3a8da8e..63f8141 100755 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -4,12 +4,20 @@ case $::osfamily { 'Debian': { class { 'uchiwa::repo::apt': } - $repo_require = Apt::Source['sensu'] + if str2bool($uchiwa::install_repo) { + $repo_require = Apt::Source['sensu'] + } else { + $repo_require = undef + } } 'RedHat': { class { 'uchiwa::repo::yum': } - $repo_require = Yumrepo['sensu'] + if str2bool($uchiwa::install_repo) { + $repo_require = Yumrepo['sensu'] + } else { + $repo_require = undef + } } default: { alert("${::osfamily} not supported yet") } diff --git a/spec/classes/uchiwa_spec.rb b/spec/classes/uchiwa_spec.rb index 8be28a7..f33ea2c 100644 --- a/spec/classes/uchiwa_spec.rb +++ b/spec/classes/uchiwa_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' describe 'uchiwa' do - let(:facts) { - { + let(:facts) { + { :osfamily => 'RedHat', :concat_basedir => '/dne', } } - + it 'should compile' do should create_class('uchiwa') end it { should contain_class('uchiwa::config')} @@ -32,12 +32,12 @@ context 'repos' do context 'ubuntu' do - let(:facts) { - { + let(:facts) { + { :osfamily => 'Debian', :fqdn => 'testhost.domain.com', - :concat_basedir => '/dne' - } + :concat_basedir => '/dne' + } } context 'with puppet-apt installed' do @@ -82,12 +82,17 @@ context 'install_repo => false' do let(:params) { { :install_repo => false, :repo => 'main' } } + it { should_not contain_apt__source('sensu') } it { should_not contain_apt__key('sensu').with( :key => '7580C77F', :key_source => 'http://repos.sensuapp.org/apt/pubkey.gpg' ) } + + it { should contain_package('uchiwa').with( + :require => nil + ) } end end @@ -120,7 +125,12 @@ context 'install_repo => false' do let(:params) { { :install_repo => false } } + it { should_not contain_yumrepo('sensu') } + + it { should contain_package('uchiwa').with( + :require => nil + ) } end end end