From 363bdd5c7519aea45be143f4a19c10dc41a9b03f 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 --- manifests/irc_bot.pp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'manifests/irc_bot.pp') diff --git a/manifests/irc_bot.pp b/manifests/irc_bot.pp index 961755a..fc47884 100644 --- a/manifests/irc_bot.pp +++ b/manifests/irc_bot.pp @@ -4,14 +4,14 @@ class nagios::irc_bot { } $nagios_nsa_socket = $nagios_nsa_socket ? { - '' => $operatingsystem ? { + '' => $::operatingsystem ? { centos => '/var/run/nagios-nsa/nsa.socket', default => '/var/run/nagios3/nsa.socket' }, default => $nagios_nsa_socket, } $nagios_nsa_pidfile = $nagios_nsa_pidfile ? { - '' => $operatingsystem ? { + '' => $::operatingsystem ? { centos => '/var/run/nagios-nsa/nsa.pid', default => '/var/run/nagios3/nsa.pid' }, @@ -40,7 +40,7 @@ class nagios::irc_bot { } file { "/etc/init.d/nagios-nsa": owner => root, group => root, 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": @@ -61,7 +61,7 @@ class nagios::irc_bot { Service['nagios'] ], } - case $operatingsystem { + case $::operatingsystem { centos: { Package['libnet-irc-perl']{ name => 'perl-Net-IRC', -- cgit v1.2.3 From 0fe7552f256f0b1508cc5d3cab952eb93bee6811 Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 5 Jun 2012 19:34:51 -0300 Subject: new style for 2.7 --- manifests/irc_bot.pp | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) (limited to 'manifests/irc_bot.pp') 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 } } -- cgit v1.2.3 From 41fe95b36253826b8f801ee1669acdb28c70076c Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 14 Jun 2012 10:36:25 -0300 Subject: take hiera out of the params --- manifests/irc_bot.pp | 146 +++++++++++++++++++++++++-------------------------- 1 file changed, 72 insertions(+), 74 deletions(-) (limited to 'manifests/irc_bot.pp') diff --git a/manifests/irc_bot.pp b/manifests/irc_bot.pp index 5d684f8..77c5fa8 100644 --- a/manifests/irc_bot.pp +++ b/manifests/irc_bot.pp @@ -1,86 +1,84 @@ 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') + $nsa_socket = 'absent', + $nsa_server, + $nsa_port = 6667, + $nsa_nickname, + $nsa_password = '', + $nsa_channel, + $nsa_pidfile = 'absent', + $nsa_realname = 'Nagios' ) { - $real_nsa_socket = $nsa_socket ? { - 'absent' => $::operatingsystem ? { - centos => '/var/run/nagios-nsa/nsa.socket', - default => '/var/run/nagios3/nsa.socket' - }, - default => $nsa_socket, - } - $real__nsa_pidfile = $nsa_pidfile ? { - 'absent' => $::operatingsystem ? { - centos => '/var/run/nagios-nsa/nsa.pid', - default => '/var/run/nagios3/nsa.pid' - }, - default => $nsa_pidfile, - } + $real_nsa_socket = $nsa_socket ? { + 'absent' => $::operatingsystem ? { + centos => '/var/run/nagios-nsa/nsa.socket', + default => '/var/run/nagios3/nsa.socket' + }, + default => $nsa_socket, + } + $real__nsa_pidfile = $nsa_pidfile ? { + 'absent' => $::operatingsystem ? { + centos => '/var/run/nagios-nsa/nsa.pid', + default => '/var/run/nagios3/nsa.pid' + }, + default => $nsa_pidfile, + } - file { "/usr/local/bin/riseup-nagios-client.pl": - owner => root, group => root, mode => 0755, - source => "puppet:///modules/nagios/irc_bot/riseup-nagios-client.pl", - } - file { "/usr/local/bin/riseup-nagios-server.pl": - owner => root, group => root, mode => 0755, - source => "puppet:///modules/nagios/irc_bot/riseup-nagios-server.pl", - } - file { "/etc/init.d/nagios-nsa": - owner => root, group => root, 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 => root, mode => 0400, - content => template('nagios/irc_bot/nsa.cfg.erb'), - } + file { + '/usr/local/bin/riseup-nagios-client.pl': + source => 'puppet:///modules/nagios/irc_bot/riseup-nagios-client.pl', + owner => root, group => root, mode => 0755; + '/usr/local/bin/riseup-nagios-server.pl': + source => 'puppet:///modules/nagios/irc_bot/riseup-nagios-server.pl', + owner => root, group => root, mode => 0755; + '/etc/init.d/nagios-nsa': + content => template("nagios/irc_bot/${::operatingsystem}/nagios-nsa.sh.erb"), + require => File['/usr/local/bin/riseup-nagios-server.pl'], + owner => root, group => root, mode => 0755; + '/etc/nagios_nsa.cfg': + ensure => present, + content => template('nagios/irc_bot/nsa.cfg.erb'), + owner => nagios, group => root, mode => 0400; + } - package { "libnet-irc-perl": - ensure => present, - } + package { 'libnet-irc-perl': + ensure => present, + } - service { "nagios-nsa": - ensure => "running", - hasstatus => true, - require => [File["/etc/nagios_nsa.cfg"], - Package["libnet-irc-perl"], - Service['nagios'] ], - } + service { "nagios-nsa": + ensure => "running", + hasstatus => true, + require => [ File["/etc/nagios_nsa.cfg"], + Package["libnet-irc-perl"], + Service['nagios'] ], + } - case $::operatingsystem { - centos: { - Package['libnet-irc-perl']{ - name => 'perl-Net-IRC', - } - Service['nagios-nsa']{ - enable => true, - } + case $::operatingsystem { + centos: { + Package['libnet-irc-perl']{ + name => 'perl-Net-IRC', } - debian,ubuntu: { - exec { "nagios_nsa_init_script": - command => "/usr/sbin/update-rc.d nagios-nsa defaults", - unless => "/bin/ls /etc/rc3.d/ | /bin/grep nagios-nsa", - require => File["/etc/init.d/nagios-nsa"], - before => Service['nagios-nsa'], - } + Service['nagios-nsa']{ + enable => true, } } - - nagios_command { - "notify-by-irc": - command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($SERVICEDESC$) $NOTIFICATIONTYPE$ n.$SERVICEATTEMPT$ $SERVICESTATETYPE$ $SERVICEEXECUTIONTIME$s $SERVICELATENCY$s $SERVICEOUTPUT$ $SERVICEPERFDATA$"'; - "host-notify-by-irc": - command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($HOSTALIAS$) $NOTIFICATIONTYPE$ n.$HOSTATTEMPT$ $HOSTSTATETYPE$ took $HOSTEXECUTIONTIME$s $HOSTOUTPUT$ $HOSTPERFDATA$ $HOSTLATENCY$s"'; + debian,ubuntu: { + exec { "nagios_nsa_init_script": + command => "/usr/sbin/update-rc.d nagios-nsa defaults", + unless => "/bin/ls /etc/rc3.d/ | /bin/grep nagios-nsa", + require => File["/etc/init.d/nagios-nsa"], + before => Service['nagios-nsa'], + } } + } - if hiera('use_shorewall',false) { - include shorewall::rules::out::irc - } + nagios_command { + 'notify-by-irc': + command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($SERVICEDESC$) $NOTIFICATIONTYPE$ n.$SERVICEATTEMPT$ $SERVICESTATETYPE$ $SERVICEEXECUTIONTIME$s $SERVICELATENCY$s $SERVICEOUTPUT$ $SERVICEPERFDATA$"'; + 'host-notify-by-irc': + command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($HOSTALIAS$) $NOTIFICATIONTYPE$ n.$HOSTATTEMPT$ $HOSTSTATETYPE$ took $HOSTEXECUTIONTIME$s $HOSTOUTPUT$ $HOSTPERFDATA$ $HOSTLATENCY$s"'; + } + + if $nagios::manage_shorewall { + include shorewall::rules::out::irc + } } -- cgit v1.2.3