Skip to content

Commit

Permalink
Merge pull request #130 from jlambert121/rem_str2bool
Browse files Browse the repository at this point in the history
remove str2bool, add repo_source
  • Loading branch information
jlambert121 committed Jan 8, 2014
2 parents 4da5e00 + 0a6d58f commit 38be61d
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 41 deletions.
2 changes: 1 addition & 1 deletion manifests/api/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

if $sensu::purge_config_real and !$sensu::server_real and !$sensu::api_real and !$sensu::dashboard_real {
if $sensu::purge_config and !$sensu::server and !$sensu::api and !$sensu::dashboard {
$ensure = 'absent'
} else {
$ensure = 'present'
Expand Down
4 changes: 2 additions & 2 deletions manifests/api/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

if $sensu::manage_services_real {
if $sensu::manage_services {

case $sensu::api_real {
case $sensu::api {
true: {
$ensure = 'running'
$enable = true
Expand Down
5 changes: 2 additions & 3 deletions manifests/check.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Default: undef
#
# [*handlers*]
# String, Array of Strings. Handlers to use for this check
# Array of Strings. Handlers to use for this check
# Default: undef
#
# [*standalone*]
Expand Down Expand Up @@ -55,7 +55,6 @@

validate_re($ensure, ['^present$', '^absent$'] )
validate_bool($standalone)
$handlers_real = any2array($handlers)
if !is_integer($interval) {
fail("sensu::check{${name}}: interval must be an integer (got: ${interval})")
}
Expand All @@ -81,7 +80,7 @@
type => $type,
standalone => $standalone,
command => $command,
handlers => $handlers_real,
handlers => $handlers,
interval => $interval,
subscribers => $subscribers,
low_flap_threshold => $low_flap_threshold,
Expand Down
4 changes: 2 additions & 2 deletions manifests/client/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

if $sensu::purge_config_real and !$sensu::client_real {
if $sensu::purge_config and !$sensu::client {
$ensure = 'absent'
} else {
$ensure = 'present'
Expand All @@ -25,7 +25,7 @@
ensure => $ensure,
client_name => $sensu::client_name,
address => $sensu::client_address,
subscriptions => $sensu::subscriptions_real,
subscriptions => $sensu::subscriptions,
safe_mode => $sensu::safe_mode,
custom => $sensu::client_custom,
}
Expand Down
4 changes: 2 additions & 2 deletions manifests/client/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

if $sensu::manage_services_real {
if $sensu::manage_services {

case $sensu::client_real {
case $sensu::client {
true: {
$ensure = 'running'
$enable = true
Expand Down
2 changes: 1 addition & 1 deletion manifests/dashboard/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

if $sensu::purge_config_real and !$sensu::dashboard_real {
if $sensu::purge_config and !$sensu::dashboard {
$ensure = 'absent'
} else {
$ensure = 'present'
Expand Down
4 changes: 2 additions & 2 deletions manifests/dashboard/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

if $sensu::manage_services_real {
if $sensu::manage_services {

case $sensu::dashboard_real {
case $sensu::dashboard {
true: {
$ensure = 'running'
$enable = true
Expand Down
11 changes: 5 additions & 6 deletions manifests/handler.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
# Default: undef
#
# [*handlers*]
# String, Array of Strings. Handlers to use when type=set
# Array of Strings. Handlers to use when type=set
# Default: undef
#
# [*severities*]
# String, Array of Strings. Severities handler is valid for
# Array of Strings. Severities handler is valid for
# Default: ['ok', 'warning', 'critical', 'unknown']
# Valid values: ok, warning, critical, unknown
#
Expand Down Expand Up @@ -70,8 +70,7 @@
validate_re($type, [ '^pipe$', '^tcp$', '^udp$', '^amqp$', '^set$' ] )
if $exchange { validate_hash($exchange) }
if $socket { validate_hash($socket) }
$handlers_real = any2array($handlers)
$severities_real = any2array($severities)
validate_array($severities)
if $source { validate_re($source, ['^puppet://'] ) }

if $type == 'pipe' and $ensure != 'absent' and !$command and !$source and !$mutator {
Expand Down Expand Up @@ -128,8 +127,8 @@
ensure => $ensure,
type => $type,
command => $command_real,
handlers => $handlers_real,
severities => $severities_real,
handlers => $handlers,
severities => $severities,
exchange => $exchange,
socket => $socket,
mutator => $mutator,
Expand Down
19 changes: 8 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
# Default: main
# Valid values: main, unstable
#
# [*repo_source*]
# String. Location of the yum/apt repo. Overrides the default location
# Default: undef
#
# [*client*]
# Boolean. Include the sensu client
# Default: true
Expand Down Expand Up @@ -107,7 +111,7 @@
# Default: secret
#
# [*subscriptions*]
# String, Array of strings. Default suscriptions used by the client
# Array of strings. Default suscriptions used by the client
# Default: []
#
# [*client_address*]
Expand Down Expand Up @@ -154,6 +158,7 @@
$version = 'latest',
$install_repo = true,
$repo = 'main',
$repo_source = undef,
$client = true,
$server = false,
$api = false,
Expand Down Expand Up @@ -186,15 +191,8 @@
$log_level = 'info',
){

$client_real = str2bool($client)
$server_real = str2bool($server)
$api_real = str2bool($api)
$dashboard_real = str2bool($dashboard)
$install_repo_real = str2bool($install_repo)
$purge_config_real = str2bool($purge_config)
$safe_mode_real = str2bool($safe_mode)
$manage_services_real = str2bool($manage_services)
$subscriptions_real = any2array($subscriptions)
validate_bool($client, $server, $api, $dashboard, $install_repo, $purge_config, $safe_mode, $manage_services)

validate_re($repo, ['^main$', '^unstable$'], "Repo must be 'main' or 'unstable'. Found: ${repo}")
validate_re($version, ['^absent$', '^installed$', '^latest$', '^present$', '^[\d\.\-]+$'], "Invalid package version: ${version}")
validate_re($log_level, ['^debug$', '^info$', '^warn$', '^error$', '^fatal$'] )
Expand All @@ -203,7 +201,6 @@
if !is_integer($api_port) { fail('api_port must be an integer') }
if !is_integer($dashboard_port) { fail('dashboard_port must be an integer') }


# Include everything and let each module determine its state. This allows
# transitioning to purged config and stopping/disabling services
anchor { 'sensu::begin': } ->
Expand Down
2 changes: 1 addition & 1 deletion manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
owner => 'sensu',
group => 'sensu',
mode => '0555',
purge => $sensu::purge_config_real,
purge => $sensu::purge_config,
recurse => true,
force => true,
require => Package['sensu'],
Expand Down
2 changes: 1 addition & 1 deletion manifests/rabbitmq/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

if $sensu::purge_config_real and !$sensu::server_real and !$sensu::client_real {
if $sensu::purge_config and !$sensu::server and !$sensu::client {
$ensure = 'absent'
} else {
$ensure = 'present'
Expand Down
2 changes: 1 addition & 1 deletion manifests/redis/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

if $sensu::purge_config_real and !$sensu::server_real and !$sensu::api_real and !$sensu::dashboard_real {
if $sensu::purge_config and !$sensu::server and !$sensu::api and !$sensu::dashboard {
$ensure = 'absent'
} else {
$ensure = 'present'
Expand Down
10 changes: 8 additions & 2 deletions manifests/repo/apt.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@

if defined(apt::source) and defined(apt::key) {

$ensure = $sensu::install_repo_real ? {
$ensure = $sensu::install_repo ? {
true => 'present',
default => 'absent'
}

if $sensu::repo_source {
$url = $sensu::repo_source
} else {
$url = 'http://repos.sensuapp.org/apt'
}

apt::source { 'sensu':
ensure => $ensure,
location => 'http://repos.sensuapp.org/apt',
location => $url,
release => 'sensu',
repos => $sensu::repo,
include_src => false,
Expand Down
12 changes: 8 additions & 4 deletions manifests/repo/yum.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

if $sensu::install_repo_real {
$url = $sensu::repo ? {
'unstable' => 'http://repos.sensuapp.org/yum-unstable/el/$releasever/$basearch/',
default => 'http://repos.sensuapp.org/yum/el/$releasever/$basearch/'
if $sensu::install_repo {
if $sensu::repo_source {
$url = $sensu::repo_source
} else {
$url = $sensu::repo ? {
'unstable' => 'http://repos.sensuapp.org/yum-unstable/el/$releasever/$basearch/',
default => 'http://repos.sensuapp.org/yum/el/$releasever/$basearch/'
}
}

yumrepo { 'sensu':
Expand Down
4 changes: 2 additions & 2 deletions manifests/server/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

if $sensu::manage_services_real {
if $sensu::manage_services {

case $sensu::server_real {
case $sensu::server {
true: {
$ensure = 'running'
$enable = true
Expand Down
10 changes: 10 additions & 0 deletions spec/classes/sensu_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
it { should contain_apt__source('sensu').with_repos('unstable') }
end

context 'override repo url' do
let(:params) { { :repo_source => 'http://repo.mydomain.com/apt' } }
it { should contain_apt__source('sensu').with( :location => 'http://repo.mydomain.com/apt') }
end

context 'install_repo => false' do
let(:params) { { :install_repo => false, :repo => 'main' } }
it { should contain_apt__source('sensu').with_ensure('absent') }
Expand Down Expand Up @@ -91,6 +96,11 @@
it { should contain_yumrepo('sensu').with(:baseurl => 'http://repos.sensuapp.org/yum-unstable/el/$releasever/$basearch/' )}
end

context 'override repo url' do
let(:params) { { :repo_source => 'http://repo.mydomain.com/yum' } }
it { should contain_yumrepo('sensu').with( :baseurl => 'http://repo.mydomain.com/yum') }
end

context 'install_repo => false' do
let(:params) { { :install_repo => false } }
it { should_not contain_yumrepo('sensu') }
Expand Down

0 comments on commit 38be61d

Please sign in to comment.