2016-10-17 04:05:49 +02:00
|
|
|
class zulip_ops::nagios {
|
|
|
|
include zulip_ops::base
|
|
|
|
include zulip_ops::apache
|
2016-04-04 04:13:34 +02:00
|
|
|
include zulip::nagios
|
2013-02-07 22:20:10 +01:00
|
|
|
|
2013-11-08 21:17:14 +01:00
|
|
|
$nagios_packages = [# Packages needed for Nagios
|
2018-08-13 21:29:40 +02:00
|
|
|
'nagios3',
|
2016-07-23 01:55:50 +02:00
|
|
|
# For sending outgoing email
|
2018-08-13 21:29:40 +02:00
|
|
|
'msmtp',
|
2013-11-08 21:17:14 +01:00
|
|
|
]
|
2018-08-13 21:29:40 +02:00
|
|
|
package { $nagios_packages: ensure => 'installed' }
|
|
|
|
$nagios_format_users = join($zulip_ops::base::users, ',')
|
|
|
|
$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', '')
|
|
|
|
$nagios_camo_check_url = zulipconf('nagios', 'camo_check_url', undef)
|
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), ',')
|
|
|
|
$hosts_postgres_primary = split(zulipconf('nagios', 'hosts_postgres_primary', undef), ',')
|
2020-06-15 20:54:50 +02:00
|
|
|
$hosts_postgres_replica = split(zulipconf('nagios', 'hosts_postgres_replica', undef), ',')
|
2018-08-13 21:29:40 +02:00
|
|
|
$hosts_redis = split(zulipconf('nagios', 'hosts_redis', undef), ',')
|
|
|
|
$hosts_loadbalancer = split(zulipconf('nagios', 'hosts_loadbalancer', undef), ',')
|
|
|
|
$hosts_stats = split(zulipconf('nagios', 'hosts_stats', undef), ',')
|
|
|
|
$hosts_fullstack = split(zulipconf('nagios', 'hosts_fullstack', undef), ',')
|
2017-10-06 04:44:52 +02:00
|
|
|
|
2013-02-07 22:20:10 +01:00
|
|
|
apache2site { 'nagios':
|
2018-08-13 21:20:34 +02:00
|
|
|
ensure => present,
|
2013-02-07 22:20:10 +01:00
|
|
|
require => [File['/etc/apache2/sites-available/'],
|
|
|
|
Apache2mod['headers'], Apache2mod['ssl'],
|
|
|
|
],
|
|
|
|
}
|
2013-05-31 21:50:57 +02:00
|
|
|
|
2018-08-13 21:29:40 +02:00
|
|
|
file { '/etc/nagios3/':
|
2013-05-31 21:50:57 +02:00
|
|
|
recurse => true,
|
2018-08-13 21:20:34 +02:00
|
|
|
purge => false,
|
2013-05-31 21:50:57 +02:00
|
|
|
require => Package[nagios3],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0644',
|
2018-08-13 21:29:40 +02:00
|
|
|
source => 'puppet:///modules/zulip_ops/nagios3/',
|
|
|
|
notify => Service['nagios3'],
|
2013-06-14 20:15:12 +02:00
|
|
|
}
|
|
|
|
|
2018-08-13 21:29:40 +02:00
|
|
|
file { '/etc/nagios3/conf.d/contacts.cfg':
|
2017-10-06 04:08:50 +02:00
|
|
|
require => Package[nagios3],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0644',
|
2018-08-13 21:29:40 +02:00
|
|
|
content => template('zulip_ops/nagios3/contacts.cfg.template.erb'),
|
|
|
|
notify => Service['nagios3'],
|
2017-10-06 04:08:50 +02:00
|
|
|
}
|
2018-08-13 21:29:40 +02:00
|
|
|
file { '/etc/nagios3/conf.d/hosts.cfg':
|
2017-10-06 04:06:28 +02:00
|
|
|
require => Package[nagios3],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0644',
|
2018-08-13 21:29:40 +02:00
|
|
|
content => template('zulip_ops/nagios3/hosts.cfg.template.erb'),
|
|
|
|
notify => Service['nagios3'],
|
2017-10-06 04:06:28 +02:00
|
|
|
}
|
2018-08-13 21:29:40 +02:00
|
|
|
file { '/etc/nagios3/conf.d/localhost.cfg':
|
2016-07-21 07:59:17 +02:00
|
|
|
require => Package[nagios3],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0644',
|
2018-08-13 21:29:40 +02:00
|
|
|
content => template('zulip_ops/nagios3/localhost.cfg.template.erb'),
|
|
|
|
notify => Service['nagios3'],
|
2016-07-21 07:59:17 +02:00
|
|
|
}
|
2017-10-06 04:06:28 +02:00
|
|
|
|
2018-08-13 21:29:40 +02:00
|
|
|
file { '/etc/nagios3/cgi.cfg':
|
2016-07-21 07:56:00 +02:00
|
|
|
require => Package[nagios3],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0644',
|
2018-08-13 21:29:40 +02:00
|
|
|
content => template('zulip_ops/nagios3/cgi.cfg.template.erb'),
|
|
|
|
notify => Service['nagios3'],
|
2016-07-21 07:56:00 +02:00
|
|
|
}
|
|
|
|
|
2018-08-13 21:29:40 +02:00
|
|
|
service { 'nagios3':
|
2013-06-14 20:15:12 +02:00
|
|
|
ensure => running,
|
|
|
|
}
|
|
|
|
|
2016-07-21 07:54:35 +02:00
|
|
|
file { [ '/etc/nagios3/conf.d/extinfo_nagios2.cfg',
|
2018-08-13 21:27:41 +02:00
|
|
|
'/etc/nagios3/conf.d/services_nagios2.cfg',
|
|
|
|
'/etc/nagios3/conf.d/contacts_nagios2.cfg',
|
|
|
|
'/etc/nagios3/conf.d/hostgroups_nagios2.cfg',
|
|
|
|
'/etc/nagios3/conf.d/localhost_nagios2.cfg',
|
|
|
|
]:
|
2016-07-21 07:54:35 +02:00
|
|
|
ensure => absent,
|
|
|
|
}
|
|
|
|
|
2013-08-07 18:22:36 +02:00
|
|
|
file { '/etc/nagios3/conf.d/zulip_nagios.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',
|
2017-10-06 03:42:13 +02:00
|
|
|
source => '/usr/local/share/zulip/integrations/nagios/zulip_nagios.cfg',
|
2018-08-13 21:29:40 +02:00
|
|
|
notify => Service['nagios3'],
|
2013-08-07 18:22:36 +02:00
|
|
|
}
|
2016-08-03 21:53:03 +02:00
|
|
|
|
|
|
|
$hosts = $zulip_ops::base::hosts
|
|
|
|
file { '/etc/nagios3/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',
|
2016-08-03 21:53:03 +02:00
|
|
|
content => template('zulip_ops/nagios_autossh.template.erb'),
|
2018-08-13 21:29:40 +02:00
|
|
|
notify => Service['nagios3'],
|
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',
|
|
|
|
content => template('zulip_ops/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
|
|
|
}
|
|
|
|
|
2018-08-13 21:29:40 +02:00
|
|
|
exec { 'fix_nagios_permissions':
|
|
|
|
command => 'dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw',
|
2018-08-28 22:44:40 +02:00
|
|
|
unless => 'bash -c "ls -ld /var/lib/nagios3/rw | grep ^drwx--s--- -q"',
|
2018-08-13 21:29:40 +02:00
|
|
|
notify => Service['nagios3'],
|
2013-06-14 20:15:12 +02:00
|
|
|
}
|
2018-08-13 21:29:40 +02:00
|
|
|
exec { 'fix_nagios_permissions2':
|
|
|
|
command => 'dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3',
|
2018-08-28 22:44:40 +02:00
|
|
|
unless => 'bash -c "ls -ld /var/lib/nagios3 | grep ^drwxr-x--x -q"',
|
2018-08-13 21:29:40 +02:00
|
|
|
notify => Service['nagios3'],
|
2013-05-31 21:50:57 +02:00
|
|
|
}
|
|
|
|
|
2018-08-13 21:29:40 +02:00
|
|
|
file { '/etc/apache2/sites-available/nagios.conf':
|
2016-07-21 07:46:02 +02:00
|
|
|
recurse => true,
|
2018-08-13 21:20:34 +02:00
|
|
|
purge => false,
|
2016-07-21 07:46:02 +02:00
|
|
|
require => Package[apache2],
|
2018-08-13 21:29:40 +02:00
|
|
|
owner => 'root',
|
|
|
|
group => 'root',
|
2018-08-13 21:20:34 +02:00
|
|
|
mode => '0640',
|
2018-08-13 21:29:40 +02:00
|
|
|
content => template('zulip_ops/nagios_apache_site.conf.template.erb'),
|
2016-07-21 07:46:02 +02:00
|
|
|
}
|
2013-02-13 22:19:08 +01:00
|
|
|
# TODO: Install our API
|
2013-02-07 22:20:10 +01:00
|
|
|
}
|