summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2012-06-05 19:34:51 -0300
committermh <mh@immerda.ch>2012-06-05 19:34:51 -0300
commit0fe7552f256f0b1508cc5d3cab952eb93bee6811 (patch)
tree9769eab5ea4b9bf6f49c2c11d9a9b9e1736361c9
parent3db1ca8f85b28978a3a9c09de3551f536b1375a6 (diff)
new style for 2.7
-rw-r--r--README67
-rw-r--r--manifests/apache.pp15
-rw-r--r--manifests/base.pp94
-rw-r--r--manifests/centos.pp2
-rw-r--r--manifests/debian.pp4
-rw-r--r--manifests/defaults/templates.pp22
-rw-r--r--manifests/defaults/vars.pp6
-rw-r--r--manifests/init.pp17
-rw-r--r--manifests/irc_bot.pp45
-rw-r--r--manifests/nsca/client.pp6
-rw-r--r--manifests/nsca/server.pp10
-rw-r--r--manifests/plugin/deploy.pp6
-rw-r--r--manifests/plugin/scriptpaths.pp2
-rw-r--r--manifests/service/ntp.pp8
-rw-r--r--manifests/service/ping.pp16
-rw-r--r--manifests/target.pp14
-rw-r--r--manifests/target/fqdn.pp4
-rw-r--r--templates/irc_bot/CentOS/nagios-nsa.sh.erb4
-rw-r--r--templates/irc_bot/Debian/nagios-nsa.sh.erb4
-rw-r--r--templates/irc_bot/nsa.cfg.erb16
20 files changed, 179 insertions, 183 deletions
diff --git a/README b/README
index 4ca4c3e..f2368ac 100644
--- a/README
+++ b/README
@@ -31,11 +31,11 @@ Hosts
-----
On a node which shall be monitored with nagios, include the "nagios::target".
-This just creates a host declaration for this host's "$ipaddress" fact. If
-the $ipaddress of your target is not the one you wish to modify, you can use
-"nagios::target::fqdn" instead, which will use the $fqdn fact of the host instead.
+This just creates a host declaration for this host's "$::ipaddress" fact. If
+the $::ipaddress of your target is not the one you wish to modify, you can use
+"nagios::target::fqdn" instead, which will use the $::fqdn fact of the host instead.
-Set the $nagios_parents variable in the node scope for enabling the reachability
+Pass the $parents variable to the target class for enabling the reachability
features of nagios. If a node needs more customisation, use the
native "@@nagios_host" type directly (the double-ampersand declares the object
as an exported resource).
@@ -72,14 +72,14 @@ Upgrade Notes
The nagios::target bits have been reworked, the notable changes that
may affect an upgrade are:
-. previous versions had nagios::target::nat which used the $fqdn for
+. previous versions had nagios::target::nat which used the $::fqdn for
the address part of nagios::target, this has been renamed to
nagios::target::fqdn to be more clear. if you were using
nagios::target::nat then you will need to change those references to
::fqdn
-. previous versions of this module used $fqdn for the nagios::target
-address, now it is using $ipaddress. If you need $fqdn, use
+. previous versions of this module used $::fqdn for the nagios::target
+address, now it is using $::ipaddress. If you need $::fqdn, use
nagios::target::fqdn instead of nagios::target
. previous versions of nagios_host used the parameter named 'ip', that
@@ -132,36 +132,38 @@ See : http://projects.reductivelabs.com/issues/1180
Variables
=========
-Options to change the behavior of the nagios module:
+Options to change the behavior of the nagios class:
-- nagios_allow_external_cmd: Set to true, if you'd like to ensure that your http
- daemon can write to the external command file. You
- may also need to flip "check_external_commands" in
- "nagios.cfg" to enable this functionality.
+- allow_external_cmd: Set to true, if you'd like to ensure that your http
+ daemon can write to the external command file. You
+ may also need to flip "check_external_commands" in
+ "nagios.cfg" to enable this functionality.
-- nagios_nsa_socket: This optional variable can be used to specify the path to
- the socket file that the IRC daemon should use.
+For the irc_bot class:
-- nagios_nsa_server: When using the IRC bot, this defines the server address of
- the IRC network on which the bot will connect.
+- nsa_socket: This optional variable can be used to specify the path to
+ the socket file that the IRC daemon should use.
-- nagios_nsa_port: Defines the port number on the IRC server on which the bot
- should connect. When this variable is not set, the port used
- by default is 6667.
+- nsa_server: When using the IRC bot, this defines the server address of
+ the IRC network on which the bot will connect.
-- nagios_nsa_nickname: This is the nickname that the IRC bot will take.
+- nsa_port: Defines the port number on the IRC server on which the bot
+ should connect. When this variable is not set, the port used
+ by default is 6667.
-- nagios_nsa_password: Some networks require a password to connect to them.
- This defines such a password.
+- nsa_nickname: This is the nickname that the IRC bot will take.
-- nagios_nsa_channel: The name of the channel that the IRC bot will join and
- will post notifications to.
+- nsa_password: Some networks require a password to connect to them.
+ This defines such a password.
-- nagios_nsa_pidfile: This optional variable can be used to define the path to
- the file that will contain the process ID of the IRC bot
- daemon.
-- nagios_nsa_realname: The IRC bot user's real name that will be displayed. By
- default, the real name is 'Nagios'.
+- nsa_channel: The name of the channel that the IRC bot will join and
+ will post notifications to.
+
+- nsa_pidfile: This optional variable can be used to define the path to
+ the file that will contain the process ID of the IRC bot
+ daemon.
+- nsa_realname: The IRC bot user's real name that will be displayed. By
+ default, the real name is 'Nagios'.
Examples
========
@@ -197,9 +199,10 @@ $HOSTADDRESS$'
node target {
- # Monitor th () is host
- $nagios_parents = 'router01'
- include nagios::target
+ # Monitor this host
+ class{'nagios::target':
+ parents = 'router01'
+ }
# monitor a service
$apache2_port = 8080
diff --git a/manifests/apache.pp b/manifests/apache.pp
index 6acf538..0696723 100644
--- a/manifests/apache.pp
+++ b/manifests/apache.pp
@@ -1,20 +1,21 @@
class nagios::apache inherits ::apache {
- $nagios_httpd = 'apache'
- include nagios
+ class{'nagios':
+ httpd => 'apache'
+ }
case $::operatingsystem {
'debian': {
- file { "${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf":
+ file { "${nagios::defaults::vars::int_cfgdir}/apache2.conf":
ensure => present,
- source => ["puppet:///site-nagios/configs/${fqdn}/apache2.conf",
- "puppet:///site-nagios/configs/apache2.conf",
+ source => ["puppet:///site_nagios/configs/${::fqdn}/apache2.conf",
+ "puppet:///site_nagios/configs/apache2.conf",
"puppet:///nagios/configs/apache2.conf"],
}
apache::config::global { "nagios3.conf":
ensure => link,
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf",
- require => File["${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf"],
+ target => "${nagios::defaults::vars::int_cfgdir}/apache2.conf",
+ require => File["${nagios::defaults::vars::int_cfgdir}/apache2.conf"],
}
}
}
diff --git a/manifests/base.pp b/manifests/base.pp
index 5a7cb7d..e706bb9 100644
--- a/manifests/base.pp
+++ b/manifests/base.pp
@@ -4,7 +4,7 @@ class nagios::base {
package { 'nagios':
alias => 'nagios',
- ensure => present,
+ ensure => present,
}
service { 'nagios':
@@ -16,21 +16,21 @@ class nagios::base {
# this file should contain all the nagios_puppet-paths:
file { 'nagios_main_cfg':
- path => "${nagios::defaults::vars::int_nagios_cfgdir}/nagios.cfg",
- source => [ "puppet:///modules/site-nagios/configs/${fqdn}/nagios.cfg",
- "puppet:///modules/site-nagios/configs/${::operatingsystem}/nagios.cfg",
- "puppet:///modules/site-nagios/configs/nagios.cfg",
+ path => "${nagios::defaults::vars::int_cfgdir}/nagios.cfg",
+ source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/nagios.cfg",
+ "puppet:///modules/site_nagios/configs/${::operatingsystem}/nagios.cfg",
+ "puppet:///modules/site_nagios/configs/nagios.cfg",
"puppet:///modules/nagios/configs/${::operatingsystem}/nagios.cfg",
"puppet:///modules/nagios/configs/nagios.cfg" ],
notify => Service['nagios'],
mode => 0644, owner => root, group => root;
- }
+ }
file { 'nagios_cgi_cfg':
- path => "${nagios::defaults::vars::int_nagios_cfgdir}/cgi.cfg",
- source => [ "puppet:///modules/site-nagios/configs/${fqdn}/cgi.cfg",
- "puppet:///modules/site-nagios/configs/${::operatingsystem}/cgi.cfg",
- "puppet:///modules/site-nagios/configs/cgi.cfg",
+ path => "${nagios::defaults::vars::int_cfgdir}/cgi.cfg",
+ source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/cgi.cfg",
+ "puppet:///modules/site_nagios/configs/${::operatingsystem}/cgi.cfg",
+ "puppet:///modules/site_nagios/configs/cgi.cfg",
"puppet:///modules/nagios/configs/${::operatingsystem}/cgi.cfg",
"puppet:///modules/nagios/configs/cgi.cfg" ],
mode => '0644', owner => 'root', group => 0,
@@ -38,14 +38,14 @@ class nagios::base {
}
file { 'nagios_htpasswd':
- path => "${nagios::defaults::vars::int_nagios_cfgdir}/htpasswd.users",
- source => [ "puppet:///modules/site-nagios/htpasswd.users",
+ path => "${nagios::defaults::vars::int_cfgdir}/htpasswd.users",
+ source => [ "puppet:///modules/site_nagios/htpasswd.users",
"puppet:///modules/nagios/htpasswd.users" ],
mode => 0640, owner => root, group => apache;
}
file { 'nagios_private':
- path => "${nagios::defaults::vars::int_nagios_cfgdir}/private/",
+ path => "${nagios::defaults::vars::int_cfgdir}/private/",
ensure => directory,
purge => true,
recurse => true,
@@ -54,15 +54,15 @@ class nagios::base {
}
file { 'nagios_private_resource_cfg':
- path => "${nagios::defaults::vars::int_nagios_cfgdir}/private/resource.cfg",
- source => [ "puppet:///modules/site-nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}",
+ path => "${nagios::defaults::vars::int_cfgdir}/private/resource.cfg",
+ source => [ "puppet:///modules/site_nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}",
"puppet:///modules/nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}" ],
notify => Service['nagios'],
owner => root, group => nagios, mode => '0640';
}
file { 'nagios_confd':
- path => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/",
+ path => "${nagios::defaults::vars::int_cfgdir}/conf.d/",
ensure => directory,
purge => true,
recurse => true,
@@ -85,88 +85,88 @@ class nagios::base {
Nagios_timeperiod <<||>>
Nagios_command <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_command.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_contact <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contact.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_contactgroup <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contactgroup.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contactgroup.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_host <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_host.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_host.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_hostdependency <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostdependency.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostdependency.cfg",
notify => Service['nagios'],
}
Nagios_hostescalation <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostescalation.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostescalation.cfg",
notify => Service['nagios'],
}
Nagios_hostextinfo <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostextinfo.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_hostgroup <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroup.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroup.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_service <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_service.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_service.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_servicegroup <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicegroup.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicegroup.cfg",
notify => Service['nagios'],
}
Nagios_servicedependency <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicedependency.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicedependency.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_serviceescalation <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceescalation.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_serviceextinfo <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceextinfo.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
Nagios_timeperiod <||> {
- target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_timeperiod.cfg",
+ target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_timeperiod.cfg",
require => File['nagios_confd'],
notify => Service['nagios'],
}
- file{[ "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_command.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contact.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contactgroup.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_host.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostdependency.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostescalation.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroup.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroupescalation.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_service.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicedependency.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicegroup.cfg",
- "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_timeperiod.cfg" ]:
+ file{[ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contactgroup.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_host.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostdependency.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostescalation.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostextinfo.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroup.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroupescalation.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_service.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicedependency.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceescalation.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceextinfo.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicegroup.cfg",
+ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_timeperiod.cfg" ]:
ensure => file,
replace => false,
notify => Service['nagios'],
@@ -176,7 +176,7 @@ class nagios::base {
# manage nagios cfg files
# must be defined after exported resource overrides and cfg file defs
file { 'nagios_cfgdir':
- path => "${nagios::defaults::vars::int_nagios_cfgdir}/",
+ path => "${nagios::defaults::vars::int_cfgdir}/",
ensure => directory,
recurse => true,
purge => true,
@@ -184,7 +184,7 @@ class nagios::base {
mode => 0755, owner => root, group => root;
}
- if $use_munin {
+ if hiera('use_munin',false) {
include nagios::munin
}
diff --git a/manifests/centos.pp b/manifests/centos.pp
index 35379b8..5a2ba23 100644
--- a/manifests/centos.pp
+++ b/manifests/centos.pp
@@ -9,7 +9,7 @@ class nagios::centos inherits nagios::base {
hasstatus => true,
}
- if ($nagios_allow_external_cmd) {
+ if $nagios::allow_external_cmd {
file { '/var/spool/nagios/cmd':
ensure => 'directory',
require => Package['nagios'],
diff --git a/manifests/debian.pp b/manifests/debian.pp
index b9e87ec..bb9bb38 100644
--- a/manifests/debian.pp
+++ b/manifests/debian.pp
@@ -14,13 +14,13 @@ class nagios::debian inherits nagios::base {
File['nagios_htpasswd', 'nagios_cgi_cfg'] { group => 'www-data' }
- file { "${nagios::defaults::vars::int_nagios_cfgdir}/stylesheets":
+ file { "${nagios::defaults::vars::int_cfgdir}/stylesheets":
ensure => directory,
purge => false,
recurse => true,
}
- if ($nagios_allow_external_cmd) {
+ if $nagios::allow_external_cmd {
exec { 'nagios_external_cmd_perms_overrides':
command => 'dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw && dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3',
unless => 'dpkg-statoverride --list nagios www-data 2710 /var/lib/nagios3/rw && dpkg-statoverride --list nagios nagios 751 /var/lib/nagios3',
diff --git a/manifests/defaults/templates.pp b/manifests/defaults/templates.pp
index aec97c0..0e73c97 100644
--- a/manifests/defaults/templates.pp
+++ b/manifests/defaults/templates.pp
@@ -1,15 +1,15 @@
class nagios::defaults::templates {
- include nagios::defaults::vars
+ include nagios::defaults::vars
- file { 'nagios_templates':
- path => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_templates.cfg",
- source => [ "puppet:///modules/site-nagios/configs/${fqdn}/nagios_templates.cfg",
- "puppet:///modules/site-nagios/configs/${::operatingsystem}/nagios_templates.cfg",
- "puppet:///modules/site-nagios/configs/nagios_templates.cfg",
- "puppet:///modules/nagios/configs/${::operatingsystem}/nagios_templates.cfg",
- "puppet:///modules/nagios/configs/nagios_templates.cfg" ],
- notify => Service['nagios'],
- mode => 0644, owner => root, group => root;
- }
+ file { 'nagios_templates':
+ path => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_templates.cfg",
+ source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/nagios_templates.cfg",
+ "puppet:///modules/site_nagios/configs/${::operatingsystem}/nagios_templates.cfg",
+ "puppet:///modules/site_nagios/configs/nagios_templates.cfg",
+ "puppet:///modules/nagios/configs/${::operatingsystem}/nagios_templates.cfg",
+ "puppet:///modules/nagios/configs/nagios_templates.cfg" ],
+ notify => Service['nagios'],
+ mode => 0644, owner => root, group => root;
+ }
}
diff --git a/manifests/defaults/vars.pp b/manifests/defaults/vars.pp
index b0aef57..87f41f8 100644
--- a/manifests/defaults/vars.pp
+++ b/manifests/defaults/vars.pp
@@ -1,10 +1,10 @@
class nagios::defaults::vars {
- case $nagios_cfgdir {
- '': { $int_nagios_cfgdir = $::operatingsystem ? {
+ case $nagios::cfgdir {
+ '': { $int_cfgdir = $::operatingsystem ? {
centos => '/etc/nagios/',
default => '/etc/nagios3'
}
}
- default: { $int_nagios_cfgdir = $nagios_cfgdir }
+ default: { $int_cfgdir = $nagios::cfgdir }
}
}
diff --git a/manifests/init.pp b/manifests/init.pp
index 5050b69..d3a00df 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -8,14 +8,17 @@
# Marcel Härry haerry+puppet(at)puzzle.ch
# Simon Josi josi+puppet(at)puzzle.ch
#
-# This program is free software; you can redistribute
-# it and/or modify it under the terms of the GNU
-# General Public License version 3 as published by
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of the GNU
+# General Public License version 3 as published by
# the Free Software Foundation.
#
-class nagios {
- case $nagios_httpd {
+class nagios(
+ $httpd = hiera('nagios_httpd','apache'),
+ $allow_external_cmd = hiera('nagios_allow_external_cmd',false),
+) {
+ case $nagios::httpd {
'absent': { }
'lighttpd': { include lighttpd }
'apache': { include apache }
@@ -23,11 +26,11 @@ class nagios {
}
case $::operatingsystem {
'centos': {
- $nagios_cfgdir = '/etc/nagios'
+ $cfgdir = '/etc/nagios'
include nagios::centos
}
'debian': {
- $nagios_cfgdir = '/etc/nagios3'
+ $cfgdir = '/etc/nagios3'
include nagios::debian
}
default: { fail("No such operatingsystem: ${::operatingsystem} yet defined") }
diff --git a/manifests/irc_bot.pp b/manifests/irc_bot.pp
index fc47884..5d684f8 100644
--- a/manifests/irc_bot.pp
+++ b/manifests/irc_bot.pp
@@ -1,33 +1,26 @@
-class nagios::irc_bot {
- if ( ! ($nagios_nsa_server and $nagios_nsa_nickname and $nagios_nsa_channel) ) {
- fail("Please provide values at least for \$nagios_nsa_server, \$nagios_nsa_nickname and \$nagios_nsa_channel")
- }
-
- $nagios_nsa_socket = $nagios_nsa_socket ? {
- '' => $::operatingsystem ? {
+class nagios::irc_bot(
+ $nsa_socket = hiera('nagios_nsa_socket','absent'),
+ $nsa_server = hiera('nagios_nsa_server'),
+ $nsa_port = hiera('nagios_nsa_port',6667),
+ $nsa_nickname = hiera('nagios_nsa_nickname'),
+ $nsa_password = hiera('nagios_nsa_password',''),
+ $nsa_channel = hiera('nagios_nsa_channel'),
+ $nsa_pidfile = hiera('nagios_nsa_pidfile','absent'),
+ $nsa_realname = hiera('nagios_nsa_realname','Nagios')
+) {
+ $real_nsa_socket = $nsa_socket ? {
+ 'absent' => $::operatingsystem ? {
centos => '/var/run/nagios-nsa/nsa.socket',
default => '/var/run/nagios3/nsa.socket'
},
- default => $nagios_nsa_socket,
+ default => $nsa_socket,
}
- $nagios_nsa_pidfile = $nagios_nsa_pidfile ? {
- '' => $::operatingsystem ? {
+ $real__nsa_pidfile = $nsa_pidfile ? {
+ 'absent' => $::operatingsystem ? {
centos => '/var/run/nagios-nsa/nsa.pid',
default => '/var/run/nagios3/nsa.pid'
},
- default => $nagios_nsa_pidfile,
- }
- $nagios_nsa_port = $nagios_nsa_port ? {
- '' => '6667',
- default => $nagios_nsa_port,
- }
- $nagios_nsa_realname = $nagios_nsa_realname ? {
- '' => 'Nagios',
- default => $nagios_nsa_realname,
- }
-
- if (! $nagios_nsa_password) {
- $nagios_nsa_password = ''
+ default => $nsa_pidfile,
}
file { "/usr/local/bin/riseup-nagios-client.pl":
@@ -64,12 +57,12 @@ class nagios::irc_bot {
case $::operatingsystem {
centos: {
Package['libnet-irc-perl']{
- name => 'perl-Net-IRC',
+ name => 'perl-Net-IRC',
}
Service['nagios-nsa']{
enable => true,
}
- }
+ }
debian,ubuntu: {
exec { "nagios_nsa_init_script":
command => "/usr/sbin/update-rc.d nagios-nsa defaults",
@@ -87,7 +80,7 @@ class nagios::irc_bot {
command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($HOSTALIAS$) $NOTIFICATIONTYPE$ n.$HOSTATTEMPT$ $HOSTSTATETYPE$ took $HOSTEXECUTIONTIME$s $HOSTOUTPUT$ $HOSTPERFDATA$ $HOSTLATENCY$s"';
}
- if $use_shorewall {
+ if hiera('use_shorewall',false) {
include shorewall::rules::out::irc
}
}
diff --git a/manifests/nsca/client.pp b/manifests/nsca/client.pp
index 6e2c472..e58721d 100644
--- a/manifests/nsca/client.pp
+++ b/manifests/nsca/client.pp
@@ -1,10 +1,10 @@
class nagios::nsca::client {
package { 'nsca': ensure => installed }
-
+
file { '/etc/send_nsca.cfg':
- source => [ "puppet:///modules/site-nagios/nsca/{$fqdn}/send_nsca.cfg",
- "puppet:///modules/site-nagios/nsca/send_nsca.cfg",
+ source => [ "puppet:///modules/site_nagios/nsca/{$::fqdn}/send_nsca.cfg",
+ "puppet:///modules/site_nagios/nsca/send_nsca.cfg",
"puppet:///modules/nagios/nsca/send_nsca.cfg" ],
owner => 'nagios',
group => 'nogroup',
diff --git a/manifests/nsca/server.pp b/manifests/nsca/server.pp
index 9239f21..8ba0116 100644
--- a/manifests/nsca/server.pp
+++ b/manifests/nsca/server.pp
@@ -1,21 +1,21 @@
class nagios::nsca::server {
package { 'nsca': ensure => installed }
-
+
service { 'nsca':
ensure => running,
hasstatus => false,
hasrestart => true,
}
-
+
file { '/etc/nsca.cfg':
- source => [ "puppet:///modules/site-nagios/nsca/{$fqdn}/nsca.cfg",
- "puppet:///modules/site-nagios/nsca/nsca.cfg",
+ source => [ "puppet:///modules/site_nagios/nsca/{$::fqdn}/nsca.cfg",
+ "puppet:///modules/site_nagios/nsca/nsca.cfg",
"puppet:///modules/nagios/nsca/nsca.cfg" ],
owner => 'nagios',
group => 'nogroup',
mode => '400',
notify => Service['nsca'],
}
-
+
}
diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp
index 96fea41..3f2a1a4 100644
--- a/manifests/plugin/deploy.pp
+++ b/manifests/plugin/deploy.pp
@@ -5,7 +5,7 @@ define nagios::plugin::deploy($source = '', $ensure = 'present', $config = '', $
default => $ensure
}
$real_source = $source ? {
- '' => "nagios/plugins/$plugin_src",
+ '' => "nagios/plugins/${plugin_src}",
default => $source
}
@@ -15,11 +15,11 @@ define nagios::plugin::deploy($source = '', $ensure = 'present', $config = '', $
tag => "nagios::plugin::deploy::package";
}
}
-
+
include nagios::plugin::scriptpaths
file { "nagios_plugin_${name}":
path => "$nagios::plugin::scriptpaths::script_path/${name}",
- source => "puppet://$server/modules/$real_source",
+ source => "puppet:///modules/${real_source}",
mode => 0755, owner => root, group => 0,
require => Package[$require_package],
tag => "nagios::plugin::deploy::file";
diff --git a/manifests/plugin/scriptpaths.pp b/manifests/plugin/scriptpaths.pp
index 6065709..9cd4b5d 100644
--- a/manifests/plugin/scriptpaths.pp
+++ b/manifests/plugin/scriptpaths.pp
@@ -1,5 +1,5 @@
class nagios::plugin::scriptpaths {
- case $hardwaremodel {
+ case $::hardwaremodel {
x86_64: { $script_path = "/usr/lib64/nagios/plugins/" }
default: { $script_path = "/usr/lib/nagios/plugins" }
}
diff --git a/manifests/service/ntp.pp b/manifests/service/ntp.pp
index eca255a..b3cde2a 100644
--- a/manifests/service/ntp.pp
+++ b/manifests/service/ntp.pp
@@ -1,9 +1,9 @@
# manifests/service/ntp.pp
class nagios::service::ntp {
- nagios::service{ "check_ntp":
- check_command => "check_ntp_time",
- host_name => $fqdn,
- }
+ nagios::service{ "check_ntp":
+ check_command => "check_ntp_time",
+ host_name => $::fqdn,
+ }
}
diff --git a/manifests/service/ping.pp b/manifests/service/ping.pp
index c705c68..80f2114 100644
--- a/manifests/service/ping.pp
+++ b/manifests/service/ping.pp
@@ -1,13 +1,9 @@
define nagios::service::ping(
- $ensure = present
+ $ensure = present,
+ $ping_rate = hiera('nagios_ping_rate','!100.0,20%!500.0,60%')
){
- $real_nagios_ping_rate = $nagios_ping_rate ? {
- '' => '!100.0,20%!500.0,60%',
- default => $nagios_ping_rate
- }
-
- nagios::service{ "check_ping":
- ensure => $ensure,
- check_command => "check_ping${real_nagios_ping_rate}",
- }
+ nagios::service{ "check_ping":
+ ensure => $ensure,
+ check_command => "check_ping${ping_rate}",
+ }
}
diff --git a/manifests/target.pp b/manifests/target.pp
index 675ac1a..fc39834 100644
--- a/manifests/target.pp
+++ b/manifests/target.pp
@@ -1,15 +1,17 @@
# manifests/target.pp
-class nagios::target {
+class nagios::target(
+ $parents = 'absent',
+) {
- @@nagios_host { "${fqdn}":
- address => $ipaddress,
- alias => $hostname,
+ @@nagios_host { $::fqdn:
+ address => $::ipaddress,
+ alias => $::hostname,
use => 'generic-host',
}
- if ($nagios_parents != '') {
- Nagios_host["${fqdn}"] { parents => $nagios_parents }
+ if ($parents != 'absent') {
+ Nagios_host["${::fqdn}"] { parents => $parents }
}
}
diff --git a/manifests/target/fqdn.pp b/manifests/target/fqdn.pp
index acac5d6..2521533 100644
--- a/manifests/target/fqdn.pp
+++ b/manifests/target/fqdn.pp
@@ -1,5 +1,3 @@
class nagios::target::fqdn inherits nagios::target {
-
- Nagios_host["${fqdn}"] { address => "${fqdn}" }
-
+ Nagios_host[$::fqdn] { address => $::fqdn }
}
diff --git a/templates/irc_bot/CentOS/nagios-nsa.sh.erb b/templates/irc_bot/CentOS/nagios-nsa.sh.erb
index 1561afd..0f9f87b 100644
--- a/templates/irc_bot/CentOS/nagios-nsa.sh.erb
+++ b/templates/irc_bot/CentOS/nagios-nsa.sh.erb
@@ -19,8 +19,8 @@
exec="/usr/local/bin/riseup-nagios-server.pl"
prog="nsa"
-PIDFILE=<%= nagios_nsa_pidfile %>
-SOCKFILE=<%= nagios_nsa_socket %>
+PIDFILE=<%= scope.lookupvar('nagios::irc_bot::real_nsa_pidfile') %>
+SOCKFILE=<%= scope.lookupvar('nagios::irc_bot::real_nsa_socket') %>
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
diff --git a/templates/irc_bot/Debian/nagios-nsa.sh.erb b/templates/irc_bot/Debian/nagios-nsa.sh.erb
index 6e608db..16fa2ea 100644
--- a/templates/irc_bot/Debian/nagios-nsa.sh.erb
+++ b/templates/irc_bot/Debian/nagios-nsa.sh.erb
@@ -9,8 +9,8 @@
# Short-Description: Nagios Simple IRC Agent
### END INIT INFO
-PIDFILE=<%= nagios_nsa_pidfile %>
-SOCKFILE=<%= nagios_nsa_socket %>
+PIDFILE=<%= scope.lookupvar('nagios::irc_bot::real_nsa_pidfile') %>
+SOCKFILE=<%= scope.lookupvar('nagios::irc_bot::real_nsa_socket') %>
. /lib/lsb/init-functions
diff --git a/templates/irc_bot/nsa.cfg.erb b/templates/irc_bot/nsa.cfg.erb
index 7cba62c..7285386 100644
--- a/templates/irc_bot/nsa.cfg.erb
+++ b/templates/irc_bot/nsa.cfg.erb
@@ -1,13 +1,13 @@
%Nsa = (
- 'socket' => '<%= nagios_nsa_socket %>',
- 'server' => '<%= nagios_nsa_server %>',
- 'port' => '<%= nagios_nsa_port %>',
- 'nickname' => '<%= nagios_nsa_nickname %>',
- 'password' => '<%= nagios_nsa_password %>',
+ 'socket' => '<%= scope.lookupvar('nagios::irc_bot::real_nsa_socket') %>',
+ 'server' => '<%= scope.lookupvar('nagios::irc_bot::nsa_server') %>',
+ 'port' => '<%= scope.lookupvar('nagios::irc_bot::nsa_port') %>',
+ 'nickname' => '<%= scope.lookupvar('nagios::irc_bot::nsa_nickname') %>',
+ 'password' => '<%= scope.lookupvar('nagios::irc_bot::nsa_password') %>',
# this needs libio-socket-ssl-perl
# doesn't actually works because Net::IRC is braindead and tries to use IO::Socket::SSL->read/write instead of the builtin print, see http://search.cpan.org/dist/IO-Socket-SSL/SSL.pm
#'SSL' => 0,
- 'channel' => '<%= nagios_nsa_channel %>',
- 'pidfile' => '<%= nagios_nsa_pidfile %>', # set to undef to disable
- 'realname' => "<%= nagios_nsa_realname %>",
+ 'channel' => '<%= scope.lookupvar('nagios::irc_bot::nsa_channel') %>',
+ 'pidfile' => '<%= scope.lookupvar('nagios::irc_bot::real_nsa_pidfile') %>', # set to undef to disable
+ 'realname' => "<%= scope.lookupvar('nagios::irc_bot::nsa_realname') %>",
);