Skip to content

Commit ed817c0

Browse files
committed
add support for quoted booleans
1 parent b12a315 commit ed817c0

9 files changed

+38
-34
lines changed

manifests/client.pp

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
$address = $::ipaddress,
1010
$subscriptions = [],
1111
$client_name = $::fqdn,
12-
$enabled = true
12+
$enabled = 'true'
1313
) {
1414

1515
$ensure = $enabled ? {
16+
'true' => 'present',
1617
true => 'present',
1718
default => 'absent'
1819
}

manifests/init.pp

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
class sensu (
1111
$rabbitmq_password,
12-
$server = false,
13-
$client = true,
12+
$server = 'false',
13+
$client = 'true',
1414
$rabbitmq_port = '5671',
1515
$rabbitmq_host = 'localhost',
1616
$rabbitmq_user = 'sensu',
@@ -43,13 +43,13 @@
4343
Class['sensu::service::client'] ->
4444
Class['sensu']
4545

46-
if $server == true {
47-
if $client == true {
46+
if $server == 'true' or $server == true {
47+
if $client == 'true' or $client == true {
4848
$notify_services = [ Class['sensu::service::client'], Class['sensu::service::server'] ]
4949
} else {
5050
$notify_services = Class['sensu::service::server']
5151
}
52-
} elsif $client == true {
52+
} elsif $client == 'true' or $client == true {
5353
$notify_services = Class['sensu::service::client']
5454
} else {
5555
$notify_services = []

manifests/server.pp

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
$dashboard_port = '8080',
1515
$dashboard_user = 'admin',
1616
$dashboard_password = 'secret',
17-
$enabled = false
17+
$enabled = 'false'
1818
) {
1919

2020
$ensure = $enabled ? {
21+
'true' => 'present',
2122
true => 'present',
22-
false => 'absent'
23+
default => 'absent'
2324
}
2425

2526
sensu_redis_config { $::fqdn:

manifests/service/client.pp

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
) {
44

55
$real_ensure = $enabled ? {
6-
true => 'running',
7-
false => 'stopped',
6+
'true' => 'running',
7+
true => 'running',
8+
default => 'stopped',
89
}
910

1011
service { 'sensu-client':

manifests/service/server.pp

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
) {
44

55
$real_ensure = $enabled ? {
6-
true => 'running',
7-
false => 'stopped',
6+
'true' => 'running',
7+
true => 'running',
8+
default => 'stopped',
89
}
910

1011
Service {

spec/classes/sensu_init_spec.rb

+12-12
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,26 @@
2626
'dashboard_port' => '8080',
2727
'dashboard_user' => 'admin',
2828
'dashboard_password' => 'secret',
29-
'enabled' => false
29+
'enabled' => 'false'
3030
)}
3131

3232
it { should contain_class('sensu::client').with(
3333
'address' => '1.2.3.4',
3434
'subscriptions' => [],
3535
'client_name' => 'myhost.domain.com',
36-
'enabled' => true
36+
'enabled' => 'true'
3737
)}
3838

39-
it { should contain_class('sensu::service::server').with_enabled(false) }
40-
it { should contain_class('sensu::service::client').with_enabled(true) }
39+
it { should contain_class('sensu::service::server').with_enabled('false') }
40+
it { should contain_class('sensu::service::client').with_enabled('true') }
4141
end
4242

4343

4444
context 'setting all params' do
4545
let(:params) { {
4646
:rabbitmq_password => 'asdfjkl',
47-
:server => true,
48-
:client => false,
47+
:server => 'true',
48+
:client => 'false',
4949
:rabbitmq_port => '1234',
5050
:rabbitmq_host => 'rabbithost',
5151
:rabbitmq_user => 'sensuuser',
@@ -85,22 +85,22 @@
8585
'dashboard_port' => '5678',
8686
'dashboard_user' => 'dashuser',
8787
'dashboard_password' => 'dashpass',
88-
'enabled' => true
88+
'enabled' => 'true'
8989
)}
9090

9191
it { should contain_class('sensu::client').with(
9292
'address' => '127.0.0.1',
9393
'subscriptions' => ['all'],
9494
'client_name' => 'myhost',
95-
'enabled' => false
95+
'enabled' => 'false'
9696
)}
9797

98-
it { should contain_class('sensu::service::server').with_enabled(true) }
99-
it { should contain_class('sensu::service::client').with_enabled(false) }
98+
it { should contain_class('sensu::service::server').with_enabled('true') }
99+
it { should contain_class('sensu::service::client').with_enabled('false') }
100100
end
101101

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

106106
it { should contain_class('sensu::rabbitmq').with(
@@ -109,7 +109,7 @@
109109
end
110110

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

115115
it { should contain_class('sensu::rabbitmq').with(

spec/classes/sensu_server_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

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

1818
it { should contain_sensu_redis_config('testhost.domain.com').with(
1919
'host' => 'localhost',
@@ -54,7 +54,7 @@
5454
:dashboard_port => '5678',
5555
:dashboard_user => 'user',
5656
:dashboard_password => 'mypass',
57-
:enabled => true
57+
:enabled => 'true'
5858
} }
5959

6060
it { should contain_sensu_redis_config('testhost.domain.com').with(
File renamed without changes.

spec/classes/sensu_service_server.pp spec/classes/sensu_service_server.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,45 @@
33
describe 'sensu::service::server', :type => :class do
44

55
context 'enabled' do
6-
let(:params) { { :enabled => true } }
6+
let(:params) { { :enabled => 'true' } }
77

88
it { should contain_service('sensu-server').with(
99
'ensure' => 'running',
10-
'enable' => true,
10+
'enable' => 'true',
1111
'hasrestart' => true
1212
) }
1313

1414
it { should contain_service('sensu-api').with(
1515
'ensure' => 'running',
16-
'enable' => true,
16+
'enable' => 'true',
1717
'hasrestart' => true
1818
) }
1919

2020
it { should contain_service('sensu-dashboard').with(
2121
'ensure' => 'running',
22-
'enable' => true,
22+
'enable' => 'true',
2323
'hasrestart' => true
2424
) }
2525
end
2626

2727
context 'disabled' do
28-
let(:params) { { :enabled => false } }
28+
let(:params) { { :enabled => 'false' } }
2929

3030
it { should contain_service('sensu-server').with(
3131
'ensure' => 'stopped',
32-
'enable' => false,
32+
'enable' => 'false',
3333
'hasrestart' => true
3434
) }
3535

3636
it { should contain_service('sensu-api').with(
3737
'ensure' => 'stopped',
38-
'enable' => false,
38+
'enable' => 'false',
3939
'hasrestart' => true
4040
) }
4141

4242
it { should contain_service('sensu-dashboard').with(
4343
'ensure' => 'stopped',
44-
'enable' => false,
44+
'enable' => 'false',
4545
'hasrestart' => true
4646
) }
4747

0 commit comments

Comments
 (0)