Puppet Class: profile::icinga
- Defined in:
- modules/profile/manifests/icinga.pp
Overview
Class: profile::icinga
Sets up a icinga instance which checks services and hosts for Wikimedia Production cluster
Parameters
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 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'modules/profile/manifests/icinga.pp', line 8
class profile::icinga(
Hash[String, Hash] $monitoring_groups = lookup('monitoring::groups'),
Hash[String, String] $ldap_config = lookup('ldap', {'merge' => 'hash'}),
String $active_host = lookup('profile::icinga::active_host'),
Array[Stdlib::Host] $partners = lookup('profile::icinga::partners'),
Enum['stopped', 'running'] $ensure_service = lookup('profile::icinga::ensure_service'),
String $virtual_host = lookup('profile::icinga::virtual_host'),
String $icinga_user = lookup('profile::icinga::icinga_user'),
String $icinga_group = lookup('profile::icinga::icinga_group'),
Stdlib::Unixpath $retention_file = lookup('profile::icinga::retention_file'),
Integer $max_concurrent_checks = lookup('profile::icinga::max_concurrent_checks'),
Stdlib::Unixpath $check_result_path = lookup('profile::icinga::check_result_path'),
Stdlib::Unixpath $temp_path = lookup('profile::icinga::temp_path'),
Stdlib::Unixpath $temp_file = lookup('profile::icinga::temp_file'),
Stdlib::Unixpath $status_file = lookup('profile::icinga::status_file'),
String $apache2_htpasswd_salt = lookup('profile::icinga::apache2_htpasswd_salt'),
Hash[String, String] $apache2_auth_users = lookup('profile::icinga::apache2_auth_users'),
Wmflib::Ensure $ircbot_ensure = lookup('profile::icinga::ircbot::ensure'),
Array[String] $datacenters = lookup('datacenters'),
Hash[String, Hash] $atlas_measurements = lookup('ripeatlas_measurements'),
Wmflib::Infra::Devices $infra_devices = lookup('infra_devices'),
Integer[1] $logs_keep_days = lookup('profile::icinga::logs_keep_days'),
Hash[String, String] $mgmt_parents = lookup('profile::icinga::mgmt_parents'),
Boolean $stub_contactgroups = lookup('profile::icinga::stub_contactgroups', {'default_value' => false}),
Integer $shard_size_warning = lookup('profile::elasticsearch::monitor::shard_size_warning', {'default_value' => 110}),
Integer $shard_size_critical = lookup('profile::elasticsearch::monitor::shard_size_critical', {'default_value' => 140}),
String $threshold = lookup('profile::elasticsearch::monitor::threshold', {'default_value' => '>=0.2'}),
Integer $timeout = lookup('profile::elasticsearch::monitor::timeout', {'default_value' => 4}),
Hash $wikimedia_clusters = lookup('wikimedia_clusters'),
){
$is_passive = !($::fqdn == $active_host)
ensure_packages('mariadb-client')
# leaving address blank means also using IPv6
class { 'rsync::server':
address => '',
}
class { 'netops::monitoring':
atlas_measurements => $atlas_measurements,
infra_devices => $infra_devices,
}
class { 'facilities':
mgmt_parents => $mgmt_parents
}
class { 'icinga::nsca::daemon':
icinga_user => $icinga_user,
icinga_group => $icinga_group,
}
class { 'icinga::monitor::toollabs': }
class { 'icinga::monitor::cloudgw': }
class { 'icinga::monitor::legal': }
class { 'icinga::monitor::certs': }
class { 'icinga::monitor::wikitech_static': }
# monitoring of content on commons (T124812)
prometheus::blackbox::check::http { 'commons.wikimedia.org':
server_name => 'commons.wikimedia.org',
instance_label => 'commons.wikimedia.org',
# Not ideal but good enough, see task for more context https://phabricator.wikimedia.org/T312840
ip4 => ipresolve("text-lb.${::site}.wikimedia.org", 4),
ip6 => ipresolve("text-lb.${::site}.wikimedia.org", 6),
path => '/wiki/Main_Page',
body_regex_matches => ['Picture of the day'],
severity => 'page',
}
class { 'icinga::monitor::elasticsearch::cirrus_cluster_checks':
shard_size_warning => $shard_size_warning,
shard_size_critical => $shard_size_critical,
timeout => $timeout,
threshold => $threshold,
}
# Experimental load-balancer monitoring for cloudelastic service using service-checker
# This was isolated from lvs::monitor_services as cloudelastic use case deviates from
# the usual use case. see T229621
class { 'icinga::monitor::cloudelastic': }
class { 'icinga::monitor::librenms': }
class { 'icinga::monitor::debmonitor': }
class { 'icinga::monitor::gitlab': }
class { 'icinga::event_handlers::raid':
icinga_user => $icinga_user,
icinga_group => $icinga_group,
}
class { 'profile::bird::anycast_monitoring': }
class { 'profile::prometheus::alerts': }
class { 'profile::prometheus::icinga_exporter': }
# Check that the public eventstreams endpoint's recentchange stream has data.
# See also: T215013. (The default params use the public endpoint.)
class { 'profile::eventstreams::monitoring': }
class { 'icinga::monitor::etcd_mw_config':
icinga_user => $icinga_user,
}
class { 'snmp::mibs': }
$wikimedia_clusters.each |String $cluster_name, Hash $cluster_config| {
$cluster_config['sites'].keys.each |String $cluster_site| {
monitoring::group { "${cluster_name}_${cluster_site}":
description => "Hosts for cluster ${cluster_name} in ${cluster_site}"
}
}
}
create_resources(monitoring::group, $monitoring_groups)
monitoring::service { 'https':
description => 'HTTPS',
check_command => "check_ssl_http_letsencrypt!${virtual_host}",
notes_url => 'https://wikitech.wikimedia.org/wiki/Icinga',
}
$ircbot_present = ($is_passive or $ircbot_ensure == 'absent') ? {
false => 'present', #aka active
true => 'absent',
}
$enable_notifications = $is_passive ? {
false => 1, #aka active
true => 0,
}
$enable_event_handlers = $is_passive ? {
false => 1, #aka active
true => 0,
}
class { 'icinga':
enable_notifications => $enable_notifications,
enable_event_handlers => $enable_event_handlers,
ensure_service => $ensure_service,
icinga_user => $icinga_user,
icinga_group => $icinga_group,
max_concurrent_checks => $max_concurrent_checks,
retention_file => $retention_file,
logs_keep_days => $logs_keep_days,
stub_contactgroups => $stub_contactgroups,
}
class { 'sslcert::dhparam': }
class { 'icinga::web':
icinga_user => $icinga_user,
icinga_group => $icinga_group,
apache2_htpasswd_salt => $apache2_htpasswd_salt,
apache2_auth_users => $apache2_auth_users,
}
profile::idp::client::httpd::site { $virtual_host:
vhost_content => 'profile/idp/client/httpd-icinga.erb',
acme_chief_cert => 'icinga',
document_root => '/usr/share/icinga/htdocs',
protected_uri => '/icinga',
cookie_scope => '/',
required_groups => [
"cn=wmf,${ldap_config['groups_cn']},${ldap_config['base-dn']}",
"cn=nda,${ldap_config['groups_cn']},${ldap_config['base-dn']}",
]
}
include profile::icinga::external_monitoring
class { 'icinga::naggen':
icinga_user => $icinga_user,
icinga_group => $icinga_group,
}
class { 'profile::icinga::ircbot':
ensure => $ircbot_present,
}
if ($is_passive) {
file { '/etc/icinga/active_host':
ensure => present,
owner => 'root',
group => 'root',
mode => '0444',
content => $active_host,
}
file { '/usr/local/sbin/sync_icinga_state':
ensure => present,
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/profile/icinga/sync_icinga_state.sh',
}
profile::auto_restarts::service { 'apache2': }
}
$all_icinga_hosts = $partners + $active_host
rsync::server::module { 'icinga-tmpfs':
read_only => 'yes',
path => '/var/icinga-tmpfs',
auto_firewall => true,
hosts_allow => $all_icinga_hosts
}
rsync::server::module { 'icinga-cache':
read_only => 'yes',
path => '/var/cache/icinga',
auto_firewall => true,
hosts_allow => $all_icinga_hosts
}
rsync::server::module { 'icinga-lib':
read_only => 'yes',
path => '/var/lib/icinga',
auto_firewall => true,
hosts_allow => $all_icinga_hosts
}
# access to the web interface
firewall::service { 'icinga-https':
proto => 'tcp',
port => 443,
}
firewall::service { 'icinga-http':
proto => 'tcp',
port => 80,
}
# allow NSCA (Nagios Service Check Acceptor)
# connections on port 5667/tcp
firewall::service { 'icinga-nsca':
proto => 'tcp',
port => 5667,
src_sets => ['DOMAIN_NETWORKS', 'FRACK_NETWORKS'],
}
# We absent the timer job on active hosts, should only exist on passive ones
$timer_job_presence = $is_passive ? {
true => 'present',
false => 'absent',
}
systemd::timer::job { 'sync-icinga-state':
ensure => $timer_job_presence,
description => 'Regular jobs to sync icinga state between hosts',
user => 'root',
command => "/usr/bin/systemd-cat -t 'sync_icinga_state' /usr/local/sbin/run-no-puppet /usr/local/sbin/sync_icinga_state",
interval => {'start' => 'OnCalendar', 'interval' => '*-*-* *:33:00'},
}
# On the passive host, replace the downtime script with a warning.
$absent_script = @("SCRIPT")
#!/bin/sh
echo 'This is not the active Icinga host. Please go to ${active_host} instead.'
exit 127
| SCRIPT
$downtime_script = $is_passive ? {
true => $absent_script,
false => file('profile/icinga/icinga-downtime.sh'),
}
# script to schedule host/service downtimes
file { '/usr/local/bin/icinga-downtime':
ensure => present,
content => $downtime_script,
owner => 'root',
group => 'root',
mode => '0550',
}
# On the passive host, display a warning in the MOTD.
$motd_presence = $is_passive ? {
true => 'present',
false => 'absent',
}
motd::script { 'inactive_warning':
ensure => $motd_presence,
priority => 1,
content => template('profile/icinga/inactive.motd.erb'),
}
$metamonitor_home = '/var/lib/metamonitor'
user { 'metamonitor':
ensure => present,
system => true,
home => $metamonitor_home,
managehome => true,
shell => '/bin/bash',
groups => $icinga_group,
}
file { "${metamonitor_home}/.ssh":
ensure => directory,
owner => 'metamonitor',
group => 'metamonitor',
mode => '0700',
}
file { "${metamonitor_home}/.ssh/known_hosts":
ensure => present,
source => 'puppet:///modules/profile/icinga/metamonitor_known_hosts',
owner => 'metamonitor',
group => 'metamonitor',
mode => '0644',
}
::keyholder::agent { 'metamonitor':
trusted_groups => ['metamonitor'],
}
systemd::timer::job { 'sync_check_icinga_contacts':
ensure => present,
description => 'Automatically sync the Icinga contacts to the metamonitoring host',
command => '/usr/local/bin/sync-check-icinga-contacts',
interval => {
'start' => 'OnCalendar',
# Daily splayed by hostname at minute 19.
# Depending on fqdn_rand seed there's the risk of not splaying
# evenly throught the day.
'interval' => "*-*-* ${sprintf('%02d', fqdn_rand(24, 1))}:19:00",
},
logging_enabled => false,
user => 'metamonitor',
require => File['/usr/local/bin/sync-check-icinga-contacts'],
}
}
|