Skip to content

Commit

Permalink
merged quoted booleans
Browse files Browse the repository at this point in the history
  • Loading branch information
jlambert121 committed Feb 25, 2013
2 parents 2ecb67f + ed817c0 commit 402c846
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 34 deletions.
3 changes: 2 additions & 1 deletion manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
$address = $::ipaddress,
$subscriptions = [],
$client_name = $::fqdn,
$enabled = true
$enabled = 'true'
) {

$ensure = $enabled ? {
'true' => 'present',
true => 'present',
default => 'absent'
}
Expand Down
10 changes: 5 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

class sensu (
$rabbitmq_password,
$server = false,
$client = true,
$server = 'false',
$client = 'true',
$version = 'latest',
$install_repo = 'true',
$rabbitmq_port = '5671',
Expand Down Expand Up @@ -45,13 +45,13 @@
Class['sensu::service::client'] ->
Class['sensu']

if $server == true {
if $client == true {
if $server == 'true' or $server == true {
if $client == 'true' or $client == true {
$notify_services = [ Class['sensu::service::client'], Class['sensu::service::server'] ]
} else {
$notify_services = Class['sensu::service::server']
}
} elsif $client == true {
} elsif $client == 'true' or $client == true {
$notify_services = Class['sensu::service::client']
} else {
$notify_services = []
Expand Down
5 changes: 3 additions & 2 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
$dashboard_port = '8080',
$dashboard_user = 'admin',
$dashboard_password = 'secret',
$enabled = false
$enabled = 'false'
) {

$ensure = $enabled ? {
'true' => 'present',
true => 'present',
false => 'absent'
default => 'absent'
}

sensu_redis_config { $::fqdn:
Expand Down
5 changes: 3 additions & 2 deletions manifests/service/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
) {

$real_ensure = $enabled ? {
true => 'running',
false => 'stopped',
'true' => 'running',
true => 'running',
default => 'stopped',
}

service { 'sensu-client':
Expand Down
5 changes: 3 additions & 2 deletions manifests/service/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
) {

$real_ensure = $enabled ? {
true => 'running',
false => 'stopped',
'true' => 'running',
true => 'running',
default => 'stopped',
}

Service {
Expand Down
22 changes: 10 additions & 12 deletions spec/classes/sensu_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,24 @@
'dashboard_port' => '8080',
'dashboard_user' => 'admin',
'dashboard_password' => 'secret',
'enabled' => false
'enabled' => 'false'
)}

it { should contain_class('sensu::client').with(
'address' => '1.2.3.4',
'subscriptions' => [],
'client_name' => 'myhost.domain.com',
'enabled' => true
'enabled' => 'true'
)}

it { should contain_class('sensu::service::server').with_enabled(false) }
it { should contain_class('sensu::service::client').with_enabled(true) }
it { should contain_class('sensu::service::server').with_enabled('false') }
it { should contain_class('sensu::service::client').with_enabled('true') }
end


context 'setting all params' do
let(:params) { {
:rabbitmq_password => 'asdfjkl',
:server => true,
:client => false,
:version => '0.9.10',
:install_repo => false,
:rabbitmq_port => '1234',
Expand Down Expand Up @@ -99,22 +97,22 @@
'dashboard_port' => '5678',
'dashboard_user' => 'dashuser',
'dashboard_password' => 'dashpass',
'enabled' => true
'enabled' => 'true'
)}

it { should contain_class('sensu::client').with(
'address' => '127.0.0.1',
'subscriptions' => ['all'],
'client_name' => 'myhost',
'enabled' => false
'enabled' => 'false'
)}

it { should contain_class('sensu::service::server').with_enabled(true) }
it { should contain_class('sensu::service::client').with_enabled(false) }
it { should contain_class('sensu::service::server').with_enabled('true') }
it { should contain_class('sensu::service::client').with_enabled('false') }
end

context 'server and client' do
let(:params) { { :rabbitmq_password => 'asdfjkl', :server => true, :client => true } }
let(:params) { { :rabbitmq_password => 'asdfjkl', :server => 'true', :client => 'true' } }
let(:facts) { { :fqdn => 'myhost.domain.com', :ipaddress => '1.2.3.4' } }

it { should contain_class('sensu::rabbitmq').with(
Expand All @@ -123,7 +121,7 @@
end

context 'neither server nor client' do
let(:params) { { :rabbitmq_password => 'asdfjkl', :server => false, :client => false } }
let(:params) { { :rabbitmq_password => 'asdfjkl', :server => 'false', :client => 'false' } }
let(:facts) { { :fqdn => 'myhost.domain.com', :ipaddress => '1.2.3.4' } }

it { should contain_class('sensu::rabbitmq').with(
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/sensu_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

context 'defaults (enabled)' do
let(:facts) { { :fqdn => 'testhost.domain.com', :ipaddress => '1.2.3.4' } }
let(:params) { { :enabled => true } }
let(:params) { { :enabled => 'true' } }

it { should contain_sensu_redis_config('testhost.domain.com').with(
'host' => 'localhost',
Expand Down Expand Up @@ -54,7 +54,7 @@
:dashboard_port => '5678',
:dashboard_user => 'user',
:dashboard_password => 'mypass',
:enabled => true
:enabled => 'true'
} }

it { should contain_sensu_redis_config('testhost.domain.com').with(
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@
describe 'sensu::service::server', :type => :class do

context 'enabled' do
let(:params) { { :enabled => true } }
let(:params) { { :enabled => 'true' } }

it { should contain_service('sensu-server').with(
'ensure' => 'running',
'enable' => true,
'enable' => 'true',
'hasrestart' => true
) }

it { should contain_service('sensu-api').with(
'ensure' => 'running',
'enable' => true,
'enable' => 'true',
'hasrestart' => true
) }

it { should contain_service('sensu-dashboard').with(
'ensure' => 'running',
'enable' => true,
'enable' => 'true',
'hasrestart' => true
) }
end

context 'disabled' do
let(:params) { { :enabled => false } }
let(:params) { { :enabled => 'false' } }

it { should contain_service('sensu-server').with(
'ensure' => 'stopped',
'enable' => false,
'enable' => 'false',
'hasrestart' => true
) }

it { should contain_service('sensu-api').with(
'ensure' => 'stopped',
'enable' => false,
'enable' => 'false',
'hasrestart' => true
) }

it { should contain_service('sensu-dashboard').with(
'ensure' => 'stopped',
'enable' => false,
'enable' => 'false',
'hasrestart' => true
) }

Expand Down

0 comments on commit 402c846

Please sign in to comment.