/
site.pp
157 lines (133 loc) · 3.44 KB
/
site.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
Exec { path => '/usr/bin:/usr/sbin:/bin:/sbin' }
node default {
if $operatingsystem in [ 'Ubuntu', 'Debian' ] {
class { 'apt':
always_apt_update => true,
before => Class['nagios']
}
}
elsif $operatingsystem in [ 'CentOS', 'RedHat' ] {
include epel
include repoforge
}
else {
fail 'Everything else unsupported'
}
$ruby_json = $operatingsystem ? {
/(Ubuntu|Debian)/ => 'ruby-json',
/(CentOS|RedHat)/ => 'rubygem-json',
default => 'ruby-json',
}
package { 'curl':
ensure => present
} ->
class { 'mailcatcher': }
class { 'nagios': } ->
class { 'icinga': } ->
class { 'flapjack': }
if $tutorial_mode == 'true' {
class { 'flapjack-diner': }
}
if $with_sensu == 'true' {
file { '/tmp/include_sensu_tests':
ensure => present,
}
class { 'rabbitmq':
} ->
rabbitmq_vhost { '/sensu':
ensure => present,
} ->
rabbitmq_user { 'admin':
admin => true,
password => 'frostyfruit5',
} ->
rabbitmq_user { 'sensu':
admin => true,
password => 'tangymango5',
} ->
rabbitmq_user_permissions { 'sensu@/sensu':
configure_permission => '.*',
read_permission => '.*',
write_permission => '.*',
} ->
package { $ruby_json:
ensure => present
} ->
class { 'redis': } ->
class { 'sensu':
install_repo => true,
server => true,
manage_services => true,
manage_user => true,
rabbitmq_password => 'tangymango5',
rabbitmq_vhost => '/sensu',
api => true,
api_user => 'admin',
api_password => 'secret',
client_address => $::ipaddress_eth0,
#plugins => [
# 'puppet:///data/sensu/plugins/ntp.rb',
#]
}
sensu::handler { 'default':
command => 'mail -s \'sensu alert\' ops@example',
}
sensu::check { 'check_ntp':
command => 'PATH=$PATH:/usr/lib/nagios/plugins check_ntp_time -H pool.ntp.org -w 30 -c 60',
handlers => 'default',
subscribers => 'sensu-test',
type => 'metric',
}
sensu::check { 'check_flapper':
command => "PATH=$PATH:/usr/lib/nagios/plugins check_tcp -H ${::ipaddress_eth0} -p 12345",
interval => 5,
handlers => 'flapjack',
standalone => true,
type => 'metric',
}
sensu::extension { 'flapjack':
source => 'puppet:///modules/sensu/extensions/handlers/flapjack.rb',
config => {
'host' => 'localhost',
'port' => '6380',
'db' => '0',
}
}
# Installs the uchiwa dashboard for sensu
# 0.0.0.0:3000
# uchiwa, uchiwa
package { 'uchiwa':
ensure => present,
} ->
file { '/etc/sensu/uchiwa.json':
ensure => present,
content => '
{
"sensu": [
{
"name": "Site1",
"host": "localhost",
"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'],
notify => Service['uchiwa'],
}
service { 'uchiwa':
ensure => running,
enable => true,
require => [ File['/etc/sensu/uchiwa.json'],Package['uchiwa'] ]
}
}
}