2024-02-06 21:40:19 +01:00
|
|
|
class kandra::profile::nagios inherits kandra::profile::base {
|
2024-02-02 15:08:49 +01:00
|
|
|
|
2024-02-06 21:40:19 +01:00
|
|
|
include kandra::apache
|
2013-02-07 22:20:10 +01:00
|
|
|
|
2024-01-31 19:41:44 +01:00
|
|
|
package { ['nagios4', 'msmtp', 'autossh']: ensure => installed }
|
2018-08-13 21:29:40 +02:00
|
|
|
$nagios_alert_email = zulipconf('nagios', 'alert_email', undef)
|
|
|
|
$nagios_test_email = zulipconf('nagios', 'test_email', undef)
|
|
|
|
$nagios_pager_email = zulipconf('nagios', 'pager_email', undef)
|
2013-02-07 22:20:10 +01:00
|
|
|
|
2018-08-13 21:29:40 +02:00
|
|
|
$nagios_mail_domain = zulipconf('nagios', 'mail_domain', undef)
|
|
|
|
$nagios_mail_host = zulipconf('nagios', 'mail_host', undef)
|
|
|
|
$nagios_mail_password = zulipsecret('secrets', 'nagios_mail_password', '')
|
2021-06-25 02:15:26 +02:00
|
|
|
if zulipconf('nagios', 'camo_check_url', undef) =~ /^https:\/\/([^\/]*)(\/.*)$/ {
|
|
|
|
$nagios_camo_check_host = $1
|
|
|
|
$nagios_camo_check_path = $2
|
|
|
|
}
|
2016-07-23 01:55:50 +02:00
|
|
|
|
2020-07-10 04:15:30 +02:00
|
|
|
$default_host_domain = zulipconf('nagios', 'default_host_domain', undef)
|
2018-08-13 21:29:40 +02:00
|
|
|
$hosts_zmirror = split(zulipconf('nagios', 'hosts_zmirror', undef), ',')
|
|
|
|
$hosts_zmirrorp = split(zulipconf('nagios', 'hosts_zmirrorp', undef), ',')
|
|
|
|
$hosts_app_prod = split(zulipconf('nagios', 'hosts_app_prod', undef), ',')
|
|
|
|
$hosts_app_staging = split(zulipconf('nagios', 'hosts_app_staging', undef), ',')
|
2020-10-26 21:56:58 +01:00
|
|
|
$hosts_postgresql_primary = split(zulipconf('nagios', 'hosts_postgresql_primary', undef), ',')
|
|
|
|
$hosts_postgresql_replica = split(zulipconf('nagios', 'hosts_postgresql_replica', undef), ',')
|
2018-08-13 21:29:40 +02:00
|
|
|
$hosts_redis = split(zulipconf('nagios', 'hosts_redis', undef), ',')
|
|
|
|
$hosts_fullstack = split(zulipconf('nagios', 'hosts_fullstack', undef), ',')
|
2021-03-18 04:04:15 +01:00
|
|
|
$hosts_smokescreen = split(zulipconf('nagios', 'hosts_smokescreen', undef), ',')
|
2022-06-14 02:12:01 +02:00
|
|
|
$hosts_other = split(zulipconf('nagios', 'hosts_other', undef), ',')
|
2017-10-06 04:44:52 +02:00
|
|
|
|
2024-02-06 21:22:32 +01:00
|
|
|
$hosts = zulipconf_nagios_hosts()
|
|
|
|
$qualified_hosts = $hosts.map |$h| { if '.' in $h { $h } else { "${h}.${default_host_domain}" }}
|
|
|
|
Kandra::User_Dotfiles['nagios'] {
|
|
|
|
keys => 'nagios',
|
|
|
|
known_hosts => $qualified_hosts,
|
|
|
|
}
|
|
|
|
|
2022-01-11 00:55:20 +01:00
|
|
|
file { '/etc/nagios4/':
|
2013-05-31 21:50:57 +02:00
|
|
|
recurse => true,
|
2018-08-13 21:20:34 +02:00
|
|
|
purge => false,
|
2022-01-11 00:55:20 +01:00
|
|
|
require => Package[nagios4],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0644',
|
2024-02-06 21:40:19 +01:00
|
|
|
source => 'puppet:///modules/kandra/nagios4/',
|
2022-01-11 00:55:20 +01:00
|
|
|
notify => Service['nagios4'],
|
2013-06-14 20:15:12 +02:00
|
|
|
}
|
|
|
|
|
2020-07-09 00:24:41 +02:00
|
|
|
file { '/etc/apache2/sites-available/nagios.conf':
|
|
|
|
purge => false,
|
|
|
|
require => Package[apache2],
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
mode => '0640',
|
2024-02-06 21:40:19 +01:00
|
|
|
content => template('kandra/nagios_apache_site.conf.template.erb'),
|
2020-07-09 00:24:41 +02:00
|
|
|
}
|
|
|
|
apache2site { 'nagios':
|
|
|
|
ensure => present,
|
|
|
|
require => [
|
|
|
|
File['/etc/apache2/sites-available/nagios.conf'],
|
|
|
|
Apache2mod['headers'], Apache2mod['ssl'],
|
|
|
|
],
|
|
|
|
notify => Service['apache2'],
|
|
|
|
}
|
2024-02-06 21:40:19 +01:00
|
|
|
kandra::teleport::application{ 'nagios':
|
2024-01-31 19:41:44 +01:00
|
|
|
description => 'Monitoring: nagios',
|
2021-06-08 23:41:02 +02:00
|
|
|
port => '3000',
|
|
|
|
}
|
2020-07-09 00:24:41 +02:00
|
|
|
|
2022-01-11 00:55:20 +01:00
|
|
|
file { '/etc/nagios4/conf.d/contacts.cfg':
|
|
|
|
require => Package[nagios4],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0644',
|
2024-02-06 21:40:19 +01:00
|
|
|
content => template('kandra/nagios4/contacts.cfg.template.erb'),
|
2022-01-11 00:55:20 +01:00
|
|
|
notify => Service['nagios4'],
|
2017-10-06 04:08:50 +02:00
|
|
|
}
|
2022-01-11 00:55:20 +01:00
|
|
|
file { '/etc/nagios4/conf.d/hosts.cfg':
|
|
|
|
require => Package[nagios4],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0644',
|
2024-02-06 21:40:19 +01:00
|
|
|
content => template('kandra/nagios4/hosts.cfg.template.erb'),
|
2022-01-11 00:55:20 +01:00
|
|
|
notify => Service['nagios4'],
|
2017-10-06 04:06:28 +02:00
|
|
|
}
|
2022-01-11 00:55:20 +01:00
|
|
|
file { '/etc/nagios4/conf.d/localhost.cfg':
|
|
|
|
require => Package[nagios4],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0644',
|
2024-02-06 21:40:19 +01:00
|
|
|
content => template('kandra/nagios4/localhost.cfg.template.erb'),
|
2022-01-11 00:55:20 +01:00
|
|
|
notify => Service['nagios4'],
|
2016-07-21 07:59:17 +02:00
|
|
|
}
|
2017-10-06 04:06:28 +02:00
|
|
|
|
2022-01-11 00:55:20 +01:00
|
|
|
file { '/etc/nagios4/cgi.cfg':
|
|
|
|
require => Package[nagios4],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0644',
|
2024-02-06 21:40:19 +01:00
|
|
|
content => template('kandra/nagios4/cgi.cfg.template.erb'),
|
2022-01-11 00:55:20 +01:00
|
|
|
notify => Service['nagios4'],
|
2016-07-21 07:56:00 +02:00
|
|
|
}
|
|
|
|
|
2022-01-11 00:55:20 +01:00
|
|
|
service { 'nagios4':
|
2024-02-06 21:22:32 +01:00
|
|
|
ensure => running,
|
|
|
|
require => Kandra::User_Dotfiles['nagios'],
|
2013-06-14 20:15:12 +02:00
|
|
|
}
|
|
|
|
|
2021-06-02 04:03:53 +02:00
|
|
|
file { [
|
2022-01-11 00:55:20 +01:00
|
|
|
'/etc/nagios4/conf.d/extinfo_nagios2.cfg',
|
|
|
|
'/etc/nagios4/conf.d/services_nagios2.cfg',
|
|
|
|
'/etc/nagios4/conf.d/contacts_nagios2.cfg',
|
|
|
|
'/etc/nagios4/conf.d/hostgroups_nagios2.cfg',
|
|
|
|
'/etc/nagios4/conf.d/localhost_nagios2.cfg',
|
2024-01-10 01:01:07 +01:00
|
|
|
'/etc/nagios4/conf.d/zulip_nagios.cfg',
|
2018-08-13 21:27:41 +02:00
|
|
|
]:
|
2016-07-21 07:54:35 +02:00
|
|
|
ensure => absent,
|
|
|
|
}
|
|
|
|
|
2024-01-31 19:41:44 +01:00
|
|
|
file { "${zulip::common::supervisor_conf_dir}/autossh_tunnels.conf":
|
|
|
|
ensure => file,
|
|
|
|
require => Package['supervisor', 'autossh'],
|
|
|
|
mode => '0644',
|
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
|
|
|
content => template('kandra/supervisor/conf.d/autossh_tunnels.conf.erb'),
|
|
|
|
notify => Service['supervisor'],
|
|
|
|
}
|
2022-01-11 00:55:20 +01:00
|
|
|
file { '/etc/nagios4/conf.d/zulip_autossh.cfg':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => file,
|
|
|
|
mode => '0644',
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2024-02-06 21:40:19 +01:00
|
|
|
content => template('kandra/nagios_autossh.template.erb'),
|
2022-01-11 00:55:20 +01:00
|
|
|
notify => Service['nagios4'],
|
2016-08-03 21:53:03 +02:00
|
|
|
}
|
2013-08-07 18:22:36 +02:00
|
|
|
|
2016-07-23 01:55:50 +02:00
|
|
|
file { '/var/lib/nagios/msmtprc':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => file,
|
|
|
|
mode => '0600',
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'nagios',
|
|
|
|
group => 'nagios',
|
2024-02-06 21:40:19 +01:00
|
|
|
content => template('kandra/msmtprc_nagios.template.erb'),
|
2018-08-13 21:20:34 +02:00
|
|
|
require => File['/var/lib/nagios'],
|
2016-07-23 01:55:50 +02:00
|
|
|
}
|
|
|
|
|
2022-11-01 20:04:16 +01:00
|
|
|
file { '/var/lib/nagios/.ssh/config':
|
|
|
|
ensure => file,
|
|
|
|
mode => '0644',
|
|
|
|
owner => 'nagios',
|
|
|
|
group => 'nagios',
|
2024-02-06 21:40:19 +01:00
|
|
|
source => 'puppet:///modules/kandra/nagios_ssh_config',
|
2022-11-01 20:04:16 +01:00
|
|
|
}
|
|
|
|
|
2022-01-11 01:54:05 +01:00
|
|
|
# Disable apparmor for msmtp so it can read the above config file
|
|
|
|
file { '/etc/apparmor.d/disable/usr.bin.msmtp':
|
|
|
|
ensure => link,
|
|
|
|
target => '/etc/apparmor.d/usr.bin.msmtp',
|
|
|
|
notify => Exec['reload apparmor'],
|
|
|
|
}
|
|
|
|
exec {'reload apparmor':
|
|
|
|
command => '/sbin/apparmor_parser -R /etc/apparmor.d/usr.bin.msmtp',
|
|
|
|
refreshonly => true,
|
|
|
|
}
|
|
|
|
|
2018-08-13 21:29:40 +02:00
|
|
|
exec { 'fix_nagios_permissions':
|
2022-01-11 00:55:20 +01:00
|
|
|
command => 'dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios4/rw',
|
|
|
|
unless => 'bash -c "ls -ld /var/lib/nagios4/rw | grep ^drwx--s--- -q"',
|
|
|
|
notify => Service['nagios4'],
|
2013-06-14 20:15:12 +02:00
|
|
|
}
|
2018-08-13 21:29:40 +02:00
|
|
|
exec { 'fix_nagios_permissions2':
|
2022-01-11 00:55:20 +01:00
|
|
|
command => 'dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios4',
|
|
|
|
unless => 'bash -c "ls -ld /var/lib/nagios4 | grep ^drwxr-x--x -q"',
|
|
|
|
notify => Service['nagios4'],
|
2013-05-31 21:50:57 +02:00
|
|
|
}
|
|
|
|
|
2013-02-13 22:19:08 +01:00
|
|
|
# TODO: Install our API
|
2013-02-07 22:20:10 +01:00
|
|
|
}
|