Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to purge handlers as well as collectors #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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