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

install plugins #27

Merged
merged 2 commits into from
Mar 1, 2013
Merged
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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ Pluginsync should be enabled. Also, you need ruby json library/gem on all your n
### Sensu Server

node "sensu-server.foo.com" {
sensu { "${::fqdn}-sensu-server": rabbitmq_password => "secret", server => true }
sensu { "${::fqdn}-sensu-server":
rabbitmq_password => "secret",
server => true,
plugins => [ 'puppet:///data/sensu/plugins/ntp.rb',
'puppet:///data/sensu/plugins/postfix.rb'
]}

sensu::check { "check_ntp":
command => 'PATH=$PATH:/usr/lib/nagios/plugins check_ntp_time -H pool.ntp.org -w 30 -c 60',
Expand Down
5 changes: 4 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
$dashboard_password = 'secret',
$subscriptions = [],
$client_address = $::ipaddress,
$client_name = $::fqdn
$client_name = $::fqdn,
$plugins = []
){

Class['sensu::package'] ->
Expand Down Expand Up @@ -97,4 +98,6 @@

class { 'sensu::service::client': enabled => $client }

sensu::plugin { $plugins: install_path => '/etc/sensu/plugins'}

}
12 changes: 12 additions & 0 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
define sensu::plugin(
$install_path = '/etc/sensu/plugins'
){

$filename = inline_template("<%= scope.lookupvar('name').split('/').last %>")

file { "${install_path}/${filename}":
ensure => file,
mode => '0555',
source => $name
}
}
6 changes: 5 additions & 1 deletion spec/classes/sensu_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
:dashboard_password => 'dashpass',
:subscriptions => ['all'],
:client_address => '127.0.0.1',
:client_name => 'myhost'
:client_name => 'myhost',
:plugins => [ 'puppet:///data/plug1', 'puppet:///data/plug2' ]
} }

it { should contain_class('sensu::package').with(
Expand Down Expand Up @@ -111,6 +112,9 @@

it { should contain_class('sensu::service::server').with_enabled('true') }
it { should contain_class('sensu::service::client').with_enabled('false') }

it { should contain_sensu__plugin('puppet:///data/plug1') }
it { should contain_sensu__plugin('puppet:///data/plug2') }
end

context 'server and client' do
Expand Down
23 changes: 23 additions & 0 deletions spec/defines/sensu_plugin_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'spec_helper'

describe 'sensu::plugin', :type => :define do
let(:title) { 'puppet:///data/plug1' }

context 'defaults' do

it { should contain_file('/etc/sensu/plugins/plug1').with(
'source' => 'puppet:///data/plug1'
) }
end

context 'setting params' do
let(:params) { {
:install_path => '/var/sensu/plugins',
} }

it { should contain_file('/var/sensu/plugins/plug1').with(
'source' => 'puppet:///data/plug1'
) }
end

end