Skip to content

Instantly share code, notes, and snippets.

@ghoneycutt
Created Nov 27, 2017
Embed
What would you like to do?
Puppet site manifest for Sensu server
# /etc/puppetlabs/code/environments/development/manifests/site.pp
# replace `sensu-server.example.com` with the FQDN of the system.
node 'sensu-server.example.com' {
## Begin dependencies for Sensu server
require ::epel
$dependencies = [
'nagios-plugins-ntp', # Not strictly needed. Used to demo a check.
'redis',
'rubygems',
'rubygem-json',
]
$dependencies.each |$dep| {
package { $dep:
ensure => 'installed',
before => Class['::sensu'],
}
}
service { 'redis':
ensure => 'running',
enable => true,
before => Class['::sensu'],
}
class { '::rabbitmq':
# By default, rabbitmq creates a user guest:guest, however they can only
# authenticate from localhost Delete the guest user since a sensu user will
# be created in the rabbitmq.sh script
delete_guest_user => true,
config_ranch => false,
require => Class['::epel'],
before => Class['::sensu'],
}
## End dependencies for Sensu server
class { '::sensu':
install_repo => true,
server => true,
manage_services => true,
manage_user => true,
rabbitmq_password => 'correct-horse-battery-staple',
rabbitmq_vhost => '/sensu',
spawn_limit => 16,
api => true,
api_user => 'admin',
api_password => 'secret',
#client_address => $::ipaddress_eth1,
subscriptions => ['all', 'roundrobin:poller'],
require => Class['::epel'],
}
## Begin setup of handler and check for demo
sensu::handler { 'default':
command => 'mail -s \'sensu alert\' ops@example.com',
}
sensu::check { 'check_ntp':
command => 'PATH=$PATH:/usr/lib64/nagios/plugins check_ntp_time -H pool.ntp.org -w 30 -c 60',
handlers => 'default',
subscribers => 'sensu-test',
}
## End setup of handler and check for demo
## Uchiwa - The Dashboard does not have it's own Puppet module
package { 'uchiwa':
ensure => 'installed',
}
file { '/etc/sensu/uchiwa.json':
ensure => file,
content => '
{
"sensu": [
{
"name": "Site1",
"host": "127.0.0.1",
"port": 4567,
"timeout": 5,
"user": "admin",
"pass": "secret"
}
],
"uchiwa": {
"host": "0.0.0.0",
"port": 3000,
"user": "uchiwa",
"pass": "uchiwa",
"interval": 5
}
}',
require => [
Package['uchiwa'],
Class['::sensu'],
],
notify => Service['uchiwa'],
}
service { 'uchiwa':
ensure => running,
enable => true,
require => [
File['/etc/sensu/uchiwa.json'],
Package['uchiwa'],
],
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment