Skip to content

Commit

Permalink
Added ability to purge handlers as well as collectors
Browse files Browse the repository at this point in the history
  • Loading branch information
justin8 committed Jun 4, 2015
1 parent 1355a5f commit bb8392a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
# [*purge_collectors*]
# Determine if we should purge collectors Puppet does not manage
#
# [*purge_handlers*]
# Determine if we should purge handlers Puppet does not manage
#
# [*install_from_pip*]
# Determine if we should install diamond from python-pip
#
Expand Down Expand Up @@ -89,6 +92,7 @@
$hostname_method = undef,
$handlers_path = undef,
$purge_collectors = false,
$purge_handlers = false,
$install_from_pip = false,
) {
class{'diamond::install': } ->
Expand Down
10 changes: 10 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@
require => File['/etc/diamond'],
}

file { '/etc/diamond/handlers':
ensure => directory,
owner => root,
group => root,
mode => '0755',
purge => $diamond::purge_handlers,
recurse => true,
require => File['/etc/diamond'],
}

if $diamond::librato_user and $diamond::librato_apikey {
ensure_packages(['python-pip'])
ensure_resource('package', 'librato-metrics', {'ensure' => 'present', 'provider' => pip, 'before' => Package['python-pip']})
Expand Down
3 changes: 3 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
"operatingsystemrelease": [
"5.11"
]
},{
"operatingsystem": "Archlinux"
}

],
"requirements": [
{
Expand Down
11 changes: 11 additions & 0 deletions spec/classes/diamond/diamond_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
it { should contain_file('/etc/diamond/diamond.conf').with_content(/interval = 30/)}

it { should contain_file('/etc/diamond/collectors').with('purge' => 'false')}
it { should contain_file('/etc/diamond/handlers').with('purge' => 'false')}

it { should_not contain_package('python-pip')}
it { should_not contain_package('librato-metrics')}
Expand Down Expand Up @@ -140,6 +141,16 @@
it { should contain_file('/etc/diamond/collectors').with('purge' => 'false')}
end

context 'with purging handlers' do
let (:params) { {'purge_handlers' => true} }
it { should contain_file('/etc/diamond/handlers').with('purge' => 'true')}
end

context 'with not purging handlers' do
let (:params) { {'purge_handlers' => false} }
it { should contain_file('/etc/diamond/handlers').with('purge' => 'false')}
end

context 'with enabling pip installation on RedHat' do
let (:params) { {'install_from_pip' => true} }
let (:facts) { {:osfamily => 'RedHat'} }
Expand Down

0 comments on commit bb8392a

Please sign in to comment.