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
|
# File 'manifests/server.pp', line 51
class icinga::server (
Boolean $ca = false,
Boolean $config_server = false,
String $zone = 'main',
Hash[String,Hash] $colocation_endpoints = {},
Hash[String,Hash] $workers = {},
Array[String] $global_zones = [],
Optional[Stdlib::Host] $ca_server = undef,
Optional[Icinga::Secret] $ticket_salt = undef,
String $web_api_user = 'icingaweb2',
Optional[Icinga::Secret] $web_api_pass = undef,
String $director_api_user = 'director',
Optional[Icinga::Secret] $director_api_pass = undef,
Enum['file', 'syslog'] $logging_type = 'file',
Optional[Icinga::LogLevel] $logging_level = undef,
Boolean $run_web = false,
) {
if empty($colocation_endpoints) {
$_ca = true
$_config_server = true
} else {
if !$ca and !$ca_server {
fail('Class[Icinga::Server]: expects a value for parameter \'ca_server\'')
}
$_ca = $ca
$_config_server = $config_server
}
# inject parent zone if no parent exists
$_workers = $workers.reduce({}) |$memo, $worker| { $memo + { $worker[0] => { parent => $zone } + $worker[1] } }
class { 'icinga':
ca => $_ca,
ca_server => $ca_server,
this_zone => $zone,
zones => { 'ZoneName' => { 'endpoints' => { 'NodeName' => {} } + $colocation_endpoints } } + $_workers,
logging_type => $logging_type,
logging_level => $logging_level,
ticket_salt => $ticket_salt,
prepare_web => $run_web,
}
include icinga2::feature::checker
include icinga2::feature::notification
icinga2::object::zone { $global_zones:
global => true,
order => 'zz',
}
if $_config_server {
if $web_api_pass {
icinga2::object::apiuser { $web_api_user:
password => $web_api_pass,
permissions => ['status/query', 'actions/*', 'objects/modify/*', 'objects/query/*'],
target => "/etc/icinga2/zones.d/${zone}/api-users.conf",
}
}
if $director_api_pass {
icinga2::object::apiuser { $director_api_user:
password => $director_api_pass,
permissions => ['*'],
target => "/etc/icinga2/zones.d/${zone}/api-users.conf",
}
}
($global_zones + keys($_workers) + $zone).each |String $dir| {
file { "${icinga2::globals::conf_dir}/zones.d/${dir}":
ensure => directory,
tag => 'icinga2::config::file',
owner => $icinga2::globals::user,
group => $icinga2::globals::group,
mode => '0750',
}
}
} else {
file { "${icinga2::globals::conf_dir}/zones.d":
ensure => directory,
purge => true,
recurse => true,
force => true,
}
}
}
|