Skip to content

Commit

Permalink
remove str2bool, add repo_source
Browse files Browse the repository at this point in the history
  • Loading branch information
jlambert121 committed Jan 7, 2014
1 parent 4da5e00 commit 14c8234
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 29 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
2 changes: 1 addition & 1 deletion 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 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
16 changes: 7 additions & 9 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 @@ -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,14 +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)
validate_bool($client, $server, $api, $dashboard, $install_repo, $purge_config, $safe_mode, $manage_services)

$subscriptions_real = any2array($subscriptions)
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}")
Expand All @@ -203,7 +202,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 14c8234

Please sign in to comment.