From e64f3a2fcc19bf6da3f81807531df740c3930657 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Thu, 14 Jul 2011 03:45:18 -0400 Subject: IRC bot: add a 'disabled' class For when you need to ensure that the bot doesn't start on a server. --- manifests/irc_bot/disabled.pp | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 manifests/irc_bot/disabled.pp (limited to 'manifests/irc_bot') diff --git a/manifests/irc_bot/disabled.pp b/manifests/irc_bot/disabled.pp new file mode 100644 index 0000000..812ef94 --- /dev/null +++ b/manifests/irc_bot/disabled.pp @@ -0,0 +1,5 @@ +class nagios::irc_bot::disabled inherits nagios::irc_bot { + Service['nagios-nsa'] { + ensure => stopped, + } +} -- cgit v1.2.3 From cde75b06b4484f705218c2ef28d49ff545d75f84 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Thu, 14 Jul 2011 05:01:09 -0400 Subject: IRC-bot: use 'enable' for Debian Since the service "disable" bug was fixed in the debian service provider [1] in the puppet 2.6.2-5 package in squeeze, let's switch from the manual calls to the "enable" feature. [1]: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=573551 Also add a requirement between service[nagios-nsa] and file[/etc/init.d/nagios-nsa]. This was ensured in Debian with the exec that we're now replacing but didn't find its way through the centosification. --- manifests/irc_bot/disabled.pp | 1 + 1 file changed, 1 insertion(+) (limited to 'manifests/irc_bot') diff --git a/manifests/irc_bot/disabled.pp b/manifests/irc_bot/disabled.pp index 812ef94..83ff15a 100644 --- a/manifests/irc_bot/disabled.pp +++ b/manifests/irc_bot/disabled.pp @@ -1,5 +1,6 @@ class nagios::irc_bot::disabled inherits nagios::irc_bot { Service['nagios-nsa'] { ensure => stopped, + enable => false, } } -- cgit v1.2.3 From 71cb2551a8f1a5a879f33f4da59dd663b038d949 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Thu, 14 Jul 2011 06:19:40 -0400 Subject: IRC-bot: rename nagios::irc_bot::disabled to nagios::irc_bot::disable All classes serving the same purpose as this one are called 'disable', so let's follow this standard. --- manifests/irc_bot/disable.pp | 8 ++++++++ manifests/irc_bot/disabled.pp | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 manifests/irc_bot/disable.pp delete mode 100644 manifests/irc_bot/disabled.pp (limited to 'manifests/irc_bot') diff --git a/manifests/irc_bot/disable.pp b/manifests/irc_bot/disable.pp new file mode 100644 index 0000000..d6b7c55 --- /dev/null +++ b/manifests/irc_bot/disable.pp @@ -0,0 +1,8 @@ +class nagios::irc_bot::disable inherits nagios::irc_bot::base { + + Service['nagios-nsa'] { + ensure => stopped, + enable => false, + } + +} diff --git a/manifests/irc_bot/disabled.pp b/manifests/irc_bot/disabled.pp deleted file mode 100644 index 83ff15a..0000000 --- a/manifests/irc_bot/disabled.pp +++ /dev/null @@ -1,6 +0,0 @@ -class nagios::irc_bot::disabled inherits nagios::irc_bot { - Service['nagios-nsa'] { - ensure => stopped, - enable => false, - } -} -- cgit v1.2.3 From db9b47560068218125cfb82b0a19a491cffba002 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Thu, 14 Jul 2011 07:03:12 -0400 Subject: IRC-bot: split up manifests by OS This gives us the possibility of using the nagios::irc_bot::disable class without having any config variable set. When using nagios::irc_bot, we still get yelled at when we didn't define the appropriate variables. While we're moving the code around, change the group applied on the different files from 'root' to '0' for better portability. --- manifests/irc_bot/base.pp | 65 +++++++++++++++++++++++++++++++++++++++++++++ manifests/irc_bot/centos.pp | 7 +++++ 2 files changed, 72 insertions(+) create mode 100644 manifests/irc_bot/base.pp create mode 100644 manifests/irc_bot/centos.pp (limited to 'manifests/irc_bot') diff --git a/manifests/irc_bot/base.pp b/manifests/irc_bot/base.pp new file mode 100644 index 0000000..2c9b27b --- /dev/null +++ b/manifests/irc_bot/base.pp @@ -0,0 +1,65 @@ +class nagios::irc_bot::base { + + # Default values for the two first variables are defined in nagios::irc_bot + $nagios_nsa_socket = $nagios_nsa_socket ? { + '' => $nagios_nsa_default_socket, + default => $nagios_nsa_socket, + } + $nagios_nsa_pidfile = $nagios_nsa_pidfile ? { + '' => $nagios_nsa_default_pidfile, + 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 = '' + } + + file { "/usr/local/bin/riseup-nagios-client.pl": + owner => root, group => 0, mode => 0755, + source => "puppet:///modules/nagios/irc_bot/riseup-nagios-client.pl", + } + file { "/usr/local/bin/riseup-nagios-server.pl": + owner => root, group => 0, mode => 0755, + source => "puppet:///modules/nagios/irc_bot/riseup-nagios-server.pl", + } + file { "/etc/init.d/nagios-nsa": + owner => root, group => 0, mode => 0755, + content => template("nagios/irc_bot/${operatingsystem}/nagios-nsa.sh.erb"), + require => File["/usr/local/bin/riseup-nagios-server.pl"], + } + file { "/etc/nagios_nsa.cfg": + ensure => present, + owner => nagios, group => 0, mode => 0400, + content => template('nagios/irc_bot/nsa.cfg.erb'), + notify => Service["nagios-nsa"], + } + + package { "libnet-irc-perl": + ensure => present, + } + + service { "nagios-nsa": + ensure => "running", + hasstatus => true, + enable => true, + require => [File["/etc/nagios_nsa.cfg"], + File["/etc/init.d/nagios-nsa"], + Package["libnet-irc-perl"], + Service['nagios'] ], + } + + nagios_command { + "notify-by-irc": + command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($SERVICEDESC$) $NOTIFICATIONTYPE$ $SERVICEATTEMPT$/$MAXSERVICEATTEMPTS$ $SERVICESTATETYPE$ $SERVICEEXECUTIONTIME$s $SERVICELATENCY$s $SERVICEOUTPUT$ $SERVICEPERFDATA$"'; + "host-notify-by-irc": + command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($HOSTALIAS$) $NOTIFICATIONTYPE$ $HOSTATTEMPT$/$MAXHOSTATTEMPTS$ $HOSTSTATETYPE$ took $HOSTEXECUTIONTIME$s $HOSTOUTPUT$ $HOSTPERFDATA$ $HOSTLATENCY$s"'; + } +} diff --git a/manifests/irc_bot/centos.pp b/manifests/irc_bot/centos.pp new file mode 100644 index 0000000..e77e93a --- /dev/null +++ b/manifests/irc_bot/centos.pp @@ -0,0 +1,7 @@ +class nagios::irc_bot::centos inherits nagios::irc_bot::base { + + Package['libnet-irc-perl']{ + name => 'perl-Net-IRC', + } + +} -- cgit v1.2.3 From 32da5faa192dc00f781bdb679aafbc0f41ac180d Mon Sep 17 00:00:00 2001 From: "Christian G. Warden" Date: Wed, 1 Feb 2012 16:56:49 -0800 Subject: Fully qualify facter variables to suppress warnings merge conflict due to immerda's branch not being up-to-date on the bot --- manifests/irc_bot/base.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests/irc_bot') diff --git a/manifests/irc_bot/base.pp b/manifests/irc_bot/base.pp index c36d8e6..ee3ea39 100644 --- a/manifests/irc_bot/base.pp +++ b/manifests/irc_bot/base.pp @@ -36,7 +36,7 @@ class nagios::irc_bot::base { } file { "/etc/init.d/nagios-nsa": owner => root, group => 0, mode => 0755, - content => template("nagios/irc_bot/${operatingsystem}/nagios-nsa.sh.erb"), + content => template("nagios/irc_bot/${::operatingsystem}/nagios-nsa.sh.erb"), require => File["/usr/local/bin/riseup-nagios-server.pl"], } file { "/etc/nagios_nsa.cfg": -- cgit v1.2.3