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
|
# File 'manifests/sensu.pp', line 2
class psick::sensu (
Psick::Password $rabbitmq_password,
Psick::Password $api_password,
String $api_user = 'sensu',
String $api_host = '127.0.0.1',
String $api_bind = '0.0.0.0',
Integer $api_port = 4567,
String $rabbitmq_host = '127.0.0.1',
String $rabbitmq_user = 'sensu',
String $rabbitmq_vhost = '/sensu',
Variant[String,Array] $subscriptions = 'base',
String $client_address = $::psick::monitor['ip'],
String $client_name = $::psick::monitor['hostname'],
Boolean $is_client = true,
Boolean $is_server = false,
Boolean $is_api = false,
String $rabbitmq_class = '',
String $redis_class = '',
String $dashboard_class = '',
Boolean $tp_test = $::psick::tp['test_enable'],
Hash $checks_hash = {},
Hash $checks_params_hash = {},
Hash $plugins_hash = {},
Hash $plugins_params_hash = {},
) {
class { '::sensu':
client => $is_client,
server => $is_server,
api => $is_api,
api_user => $api_user,
api_password => $api_password,
api_bind => $api_bind,
api_host => $api_host,
api_port => $api_port,
rabbitmq_user => $rabbitmq_user,
rabbitmq_password => $rabbitmq_password,
rabbitmq_vhost => $rabbitmq_vhost,
rabbitmq_host => $rabbitmq_host,
subscriptions => $subscriptions,
client_address => $client_address,
client_name => $client_name,
}
if $rabbitmq_class != '' {
contain $rabbitmq_class
#
rabbitmq_user { $rabbitmq_user:
admin => true,
password => $rabbitmq_password,
}
rabbitmq_vhost { $rabbitmq_vhost:
ensure => present,
}
rabbitmq_user_permissions { "${rabbitmq_user}@${rabbitmq_vhost}":
configure_permission => '.*',
read_permission => '.*',
write_permission => '.*',
}
}
if $dashboard_class != '' {
contain $dashboard_class
}
if $redis_class != '' {
contain $redis_class
}
if $checks_hash != {} {
$checks_hash.each | $k,$v | {
::sensu::check { $k:
* => $checks_params_hash + $v,
}
}
}
if $plugins_hash != {} {
$plugins_hash.each | $k,$v | {
::sensu::plugin { $k:
* => $plugins_params_hash + $v,
}
}
}
# We like sensu module, but we may want to tp test its resources
# According to the installed components
if $tp_test {
$service_client = $is_client ? {
true => ['sensu-client'],
false => [],
}
$service_api = $is_api ? {
true => ['sensu-api'],
false => [],
}
$service_server = $is_server ? {
true => ['sensu-server'],
false => [],
}
$logfile_client = $is_client ? {
true => ['/var/log/sensu/sensu-client.log'],
false => [],
}
$logfile_api = $is_api ? {
true => ['/var/log/sensu/sensu-api.log'],
false => [],
}
$logfile_server = $is_server ? {
true => ['/var/log/sensu/sensu-server.log'],
false => [],
}
tp::install { 'sensu':
manage_package => false,
manage_service => false,
settings_hash => {
'service_name' => $service_client + $service_api + $service_server,
'log_file_path' => $logfile_client + $logfile_api + $logfile_server,
},
}
}
}
|