Puppet Class: nagios::server
- Inherits:
- nagios::params
- Defined in:
- manifests/server.pp
Overview
Nagios::Server
Install a nagios server
-
collect
True if should collect and realize all nagios resources and tagged configuration files -
monitor_tag
Plaintext tag for nagios configuration files we should collect -
apache_conf_dir
Directory to write apache configuration files to -
htpasswd
Full path to .htpasswd file -
password
Password for the nagios user -
realm
Directory to manage passwords for (/nagios
)
Authors
Brett Gray Geoff Williams
Copyright
Copyright 2016 Puppet, Inc.
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 |
# File 'manifests/server.pp', line 30
class nagios::server(
$collect = true,
$monitor_tag = "__MONITOR__",
$apache_conf_dir = $nagios::params::apache_conf_dir,
$htpasswd = $nagios::params::htpasswd,
$password = "changeme",
$realm = "/nagios",
$service = $nagios::params::service,
$port = $nagios::params::port,
$purge = true,
) inherits nagios::params {
if ! defined(Class['nagios']) {
fail('You must include the nagios base class before using the nagios::server class')
}
$packages = $nagios::params::packages
$nagios_conf_dir = $nagios::params::nagios_conf_dir
$apache_group = $nagios::params::apache_group
$apache_conf = "${apache_conf_dir}/${service}.conf"
$nagios_cfg_file = $nagios::params::nagios_cfg_file
$nagios_group = $nagios::params::nagios_group
include epel
if $purge {
resources{ 'nagios_service':
purge => true
}
resources{ 'nagios_host':
purge => true
}
}
package { $packages:
ensure => present,
require => Class['epel'],
}
file { "${nagios_conf_dir}/conf.d":
ensure => directory,
owner => 'nagios',
group => 'nagios',
mode => '0755',
require => Package[$packages],
}
httpauth { 'nagiosadmin':
ensure => present,
file => $htpasswd,
password => $password,
realm => $realm,
mechanism => 'basic',
require => Package[$packages],
}
file { $htpasswd:
ensure => file,
owner => 'root',
group => $apache_group,
mode => '0640',
require => Package[$packages],
}
file { $apache_conf:
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => template("${module_name}/nagios_${osfamily}.conf.erb"),
notify => Service['httpd']
}
service { $service:
ensure => running,
enable => true,
subscribe => File[$apache_conf],
}
if $collect {
File <<| tag == $monitor_tag |>>
# collects to /etc/nagios/nagios_host.cfg, set by the type and provider
Nagios_host <<||>>
Nagios_host <||> {
require => Package[$packages],
}
# collects to /etc/nagios/nagios_service.cfg, set by the type and provider
Nagios_service <<||>>
Nagios_service <||> {
require => Package[$packages],
}
# Tell nagios about the above settings
file_line { "puppet_nagios_host":
ensure => present,
path => $nagios_cfg_file,
line => 'cfg_file=nagios_host.cfg',
notify => Service[$service],
require => Package[$packages],
}
file_line { "puppet_nagios_service":
ensure => present,
path => $nagios_cfg_file,
line => 'cfg_file=nagios_service.cfg',
notify => Service[$service],
require => Package[$packages],
}
# fix permissions on puppet-generated cfg files
file { ['/etc/nagios/nagios_host.cfg', '/etc/nagios/nagios_service.cfg']:
ensure => file,
owner => 'root',
group => $nagios_group,
mode => '0640',
notify => Service[$service],
require => Package[$packages],
}
}
}
|