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
158
159
160
161
|
# File 'manifests/mod/monitoring.pp', line 3
class icingaweb2::mod::monitoring (
$protected_customvars = '*pw*,*pass*,community',
$backend_type = 'ido',
$backend_resource = 'icinga_ido',
$transport = 'local',
$transport_host = undef,
$transport_port = undef,
$transport_username = undef,
$transport_password = undef,
$transport_path = '/var/run/icinga2/cmd/icinga2.cmd',
) {
require ::icingaweb2
validate_re($transport, '^(local|remote|api)$', 'Supported transports are local, remote or api')
if $transport != 'api' {
validate_absolute_path($transport_path)
}
if $transport != 'api' and $transport_password {
fail('transport_password only works with transport => api')
}
if $transport_port {
validate_numeric($transport_port)
$_port = $transport_port
} elsif $transport == 'api' {
$_port = 5665
} else {
$_port = 22
}
File {
require => Class['::icingaweb2::config'],
owner => $::icingaweb2::config_user,
group => $::icingaweb2::config_group,
mode => $::icingaweb2::config_file_mode,
}
$monitoring_mod_files = [
"${::icingaweb2::config_dir}/modules/monitoring/backends.ini",
"${::icingaweb2::config_dir}/modules/monitoring/config.ini",
"${::icingaweb2::config_dir}/modules/monitoring/commandtransports.ini",
]
file { $monitoring_mod_files:
ensure => present,
}
file { "${::icingaweb2::config_dir}/modules/monitoring":
ensure => directory,
mode => $::icingaweb2::config_dir_mode;
}
Ini_Setting {
ensure => present,
require => File["${::icingaweb2::config_dir}/modules/monitoring"],
}
ini_setting { 'security settings':
section => 'security',
setting => 'protected_customvars',
value => "\"${protected_customvars}\"",
path => "${::icingaweb2::config_dir}/modules/monitoring/config.ini",
}
ini_setting { 'backend ido setting':
section => 'icinga_ido',
setting => 'type',
value => $backend_type,
path => "${::icingaweb2::config_dir}/modules/monitoring/backends.ini",
}
ini_setting { 'backend resource setting':
section => 'icinga_ido',
setting => 'resource',
value => $backend_resource,
path => "${::icingaweb2::config_dir}/modules/monitoring/backends.ini",
}
ini_setting { 'command transport setting':
section => 'icinga2',
setting => 'transport',
value => $transport,
path => "${::icingaweb2::config_dir}/modules/monitoring/commandtransports.ini",
}
if $transport == 'local' or $transport == 'remote' {
$_path_ensure = present
} else {
$_path_ensure = absent
}
ini_setting { 'command transport path setting':
ensure => $_path_ensure,
section => 'icinga2',
setting => 'path',
value => $transport_path,
path => "${::icingaweb2::config_dir}/modules/monitoring/commandtransports.ini",
}
if $transport == 'remote' or $transport == 'api' {
ini_setting { 'command transport host setting':
section => 'icinga2',
setting => 'host',
value => $transport_host,
path => "${::icingaweb2::config_dir}/modules/monitoring/commandtransports.ini",
}
ini_setting { 'command transport port setting':
section => 'icinga2',
setting => 'port',
value => $_port,
path => "${::icingaweb2::config_dir}/modules/monitoring/commandtransports.ini",
}
}
$_user_ensure = $transport ? {
'remote' => present,
default => absent,
}
ini_setting { 'command transport user setting':
ensure => $_user_ensure,
section => 'icinga2',
setting => 'user',
value => $transport_username,
path => "${::icingaweb2::config_dir}/modules/monitoring/commandtransports.ini",
}
$_username_ensure = $transport ? {
'api' => present,
default => absent,
}
ini_setting { 'command transport username setting':
ensure => $_username_ensure,
section => 'icinga2',
setting => 'username',
value => $transport_username,
path => "${::icingaweb2::config_dir}/modules/monitoring/commandtransports.ini",
}
$_password_ensure = $transport ? {
'api' => present,
default => absent,
}
ini_setting { 'command transport password setting':
ensure => $_password_ensure,
section => 'icinga2',
setting => 'password',
value => $transport_password,
path => "${::icingaweb2::config_dir}/modules/monitoring/commandtransports.ini",
}
file { "${::icingaweb2::config_dir}/enabledModules/monitoring":
ensure => link,
target => '/usr/share/icingaweb2/modules/monitoring'
}
}
|