Skip to content

Commit

Permalink
Merge pull request #18 from jlambert121/repo_optional
Browse files Browse the repository at this point in the history
Enhance package options
  • Loading branch information
jamtur01 committed Feb 26, 2013
2 parents fa3fb32 + 158975b commit 63a649b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
9 changes: 8 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
$rabbitmq_password,
$server = 'false',
$client = 'true',
$version = 'latest',
$install_repo = 'true',
$rabbitmq_port = '5671',
$rabbitmq_host = 'localhost',
$rabbitmq_user = 'sensu',
Expand Down Expand Up @@ -55,7 +57,12 @@
$notify_services = []
}

class { 'sensu::package': }
class { 'sensu::package':
version => $version,
install_repo => $install_repo,
notify_services => $notify_services
}

class { 'sensu::rabbitmq':
ssl_cert_chain => $rabbitmq_ssl_cert_chain,
ssl_private_key => $rabbitmq_ssl_private_key,
Expand Down
13 changes: 10 additions & 3 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
# == Parameters
#

class sensu::package {
class sensu::package(
$version = 'latest',
$notify_services = [],
$install_repo = 'true'
) {

include sensu::repo
if $install_repo == 'true' or $install_repo == true {
include sensu::repo
}

package { 'sensu':
ensure => latest,
ensure => $version,
notify => $notify_services
}

sensu_clean_config { $::fqdn: }
Expand Down
18 changes: 16 additions & 2 deletions spec/classes/sensu_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
let(:params) { { :rabbitmq_password => 'asdfjkl' } }
let(:facts) { { :fqdn => 'myhost.domain.com', :ipaddress => '1.2.3.4' } }

it { should contain_class('sensu::package').with(
'version' => 'latest',
'install_repo' => true,
'notify_services' => 'Class[Sensu::Service::Client]'
)}

it { should contain_class('sensu::rabbitmq').with(
'ssl_cert_chain' => '',
'ssl_private_key' => '',
Expand Down Expand Up @@ -44,8 +50,10 @@
context 'setting all params' do
let(:params) { {
:rabbitmq_password => 'asdfjkl',
:server => 'true',
:client => 'false',
:server => true,
:client => false,
:version => '0.9.10',
:install_repo => false,
:rabbitmq_port => '1234',
:rabbitmq_host => 'rabbithost',
:rabbitmq_user => 'sensuuser',
Expand All @@ -65,6 +73,12 @@
:client_name => 'myhost'
} }

it { should contain_class('sensu::package').with(
'version' => '0.9.10',
'install_repo' => false,
'notify_services' => 'Class[Sensu::Service::Server]'
)}

it { should contain_class('sensu::rabbitmq').with(
'ssl_cert_chain' => '/etc/sensu/ssl/cert.pem',
'ssl_private_key' => '/etc/sensu/ssl/key.pem',
Expand Down
24 changes: 20 additions & 4 deletions spec/classes/sensu_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,25 @@
describe 'sensu::package', :type => :class do
let(:facts) { { :fqdn => 'testhost.domain.com' } }

it { should create_class('sensu::package') }
it { should include_class('sensu::repo') }
it { should contain_package('sensu').with_ensure('latest') }
it { should contain_sensu_clean_config('testhost.domain.com') }
context 'defaults' do
it { should create_class('sensu::package') }
it { should include_class('sensu::repo') }
it { should contain_package('sensu').with_ensure('latest') }
it { should contain_sensu_clean_config('testhost.domain.com') }
end

context 'setting parameters' do
let(:params) { {
:version => '0.9.10',
:install_repo => false,
:notify_services => 'Class[Sensu::Service::Server]'
} }

it { should_not include_class('sensu::repo') }
it { should contain_package('sensu').with(
'ensure' => '0.9.10',
'notify' => 'Class[Sensu::Service::Server]'
) }
end

end

0 comments on commit 63a649b

Please sign in to comment.