diff options
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/base.pp | 200 | ||||
-rw-r--r-- | manifests/plugin.pp | 34 | ||||
-rw-r--r-- | manifests/service.pp | 2 | ||||
-rw-r--r-- | manifests/target.pp | 12 |
4 files changed, 137 insertions, 111 deletions
diff --git a/manifests/base.pp b/manifests/base.pp index 3a0765a..687261d 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -22,9 +22,9 @@ class nagios::base { "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, + notify => Service['nagios'], require => Package['nagios'], + mode => 0644, owner => root, group => root; } file { 'nagios_cgi_cfg': @@ -43,27 +43,35 @@ class nagios::base { 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, require => Package['nagios'], + mode => 0640, owner => root, group => apache; } - file { 'nagios_private': - path => "${nagios::defaults::vars::int_cfgdir}/private/", - ensure => directory, - purge => true, - recurse => true, - notify => Service['nagios'], - mode => '0750', owner => root, group => nagios, - require => Package['nagios'], + if $::operatingsystem == 'Centos' { + file { 'nagios_private': + ensure => directory, + path => "${nagios::defaults::vars::int_cfgdir}/private/", + purge => true, + recurse => true, + mode => '0750', + owner => 'root', + group => 'nagios', + require => Package['nagios'], + notify => Service['nagios'], + } + + $resource_cfg_dir = "${nagios::defaults::vars::int_cfgdir}/private" + } + else { + $resource_cfg_dir = $nagios::defaults::vars::int_cfgdir } file { 'nagios_private_resource_cfg': - path => "${nagios::defaults::vars::int_cfgdir}/private/resource.cfg", + path => "${resource_cfg_dir}/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', - require => Package['nagios'], + owner => root, group => nagios, mode => '0640'; } file { 'nagios_confd': @@ -72,82 +80,91 @@ class nagios::base { purge => true, recurse => true, notify => Service['nagios'], - mode => '0750', owner => root, group => nagios, require => Package['nagios'], + mode => '0750', owner => root, group => nagios; } - if ( $nagios::stored_config == true ) { - include nagios::stored_config + Nagios_command <<||>> + Nagios_contactgroup <<||>> + Nagios_contact <<||>> + Nagios_hostdependency <<||>> + Nagios_hostescalation <<||>> + Nagios_hostextinfo <<||>> + Nagios_hostgroup <<||>> + Nagios_host <<||>> + Nagios_servicedependency <<||>> + Nagios_serviceescalation <<||>> + Nagios_servicegroup <<||>> + Nagios_serviceextinfo <<||>> + Nagios_service <<||>> + Nagios_timeperiod <<||>> + + Nagios_command <||> { + 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_cfgdir}/conf.d/nagios_contact.cfg", + require => File['nagios_confd'], + notify => Service['nagios'], + } + Nagios_contactgroup <||> { + 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_cfgdir}/conf.d/nagios_host.cfg", + require => File['nagios_confd'], + notify => Service['nagios'], + } + Nagios_hostdependency <||> { + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostdependency.cfg", + notify => Service['nagios'], + } + Nagios_hostescalation <||> { + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostescalation.cfg", + notify => Service['nagios'], + } + Nagios_hostextinfo <||> { + 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_cfgdir}/conf.d/nagios_hostgroup.cfg", + require => File['nagios_confd'], + notify => Service['nagios'], + } + Nagios_service <||> { + 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_cfgdir}/conf.d/nagios_servicegroup.cfg", + notify => Service['nagios'], + } + Nagios_servicedependency <||> { + 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_cfgdir}/conf.d/nagios_serviceescalation.cfg", + require => File['nagios_confd'], + notify => Service['nagios'], + } + Nagios_serviceextinfo <||> { + 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_cfgdir}/conf.d/nagios_timeperiod.cfg", + require => File['nagios_confd'], + notify => Service['nagios'], } - Nagios_command <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg", - require => [ File['nagios_confd'], Package['nagios'] ], - notify => Service['nagios'], - } - Nagios_contact <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg", - require => [ File['nagios_confd'], Package['nagios'] ], - notify => Service['nagios'], - } - Nagios_contactgroup <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contactgroup.cfg", - require => [ File['nagios_confd'], Package['nagios'] ], - notify => Service['nagios'], - } - Nagios_host <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_host.cfg", - require => [ File['nagios_confd'], Package['nagios'] ], - notify => Service['nagios'], - } - Nagios_hostdependency <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostdependency.cfg", - notify => Service['nagios'], - require => Package['nagios'], - } - Nagios_hostescalation <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostescalation.cfg", - notify => Service['nagios'], - require => Package['nagios'], - } - Nagios_hostextinfo <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostextinfo.cfg", - require => [ File['nagios_confd'], Package['nagios'] ], - notify => Service['nagios'], - } - Nagios_hostgroup <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroup.cfg", - require => [ File['nagios_confd'], Package['nagios'] ], - notify => Service['nagios'], - } - Nagios_service <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_service.cfg", - require => [ File['nagios_confd'], Package['nagios'] ], - notify => Service['nagios'], - } - Nagios_servicegroup <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicegroup.cfg", - notify => Service['nagios'], - require => Package['nagios'], - } - Nagios_servicedependency <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicedependency.cfg", - require => [ File['nagios_confd'], Package['nagios'] ], - notify => Service['nagios'], - } - Nagios_serviceescalation <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceescalation.cfg", - require => [ File['nagios_confd'], Package['nagios'] ], - notify => Service['nagios'], - } - Nagios_serviceextinfo <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceextinfo.cfg", - require => [ File['nagios_confd'], Package['nagios'] ], - notify => Service['nagios'], - } - Nagios_timeperiod <||> { - target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_timeperiod.cfg", - require => [ File['nagios_confd'], Package['nagios'] ], - notify => Service['nagios'], - } file{[ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg", "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg", @@ -167,8 +184,8 @@ class nagios::base { ensure => file, replace => false, notify => Service['nagios'], - mode => 0644, owner => root, group => 0, require => Package['nagios'], + mode => 0644, owner => root, group => 0; } # manage nagios cfg files @@ -179,12 +196,7 @@ class nagios::base { recurse => true, purge => true, notify => Service['nagios'], - mode => 0755, owner => root, group => root, require => Package['nagios'], + mode => 0755, owner => root, group => root; } - - file { [ '/usr/lib64', '/usr/lib64/nagios', '/usr/lib64/nagios/plugins/' ]: - ensure => directory - } - } diff --git a/manifests/plugin.pp b/manifests/plugin.pp index d32606b..f2e4ed2 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -1,19 +1,27 @@ define nagios::plugin( - $source = 'absent', - $ensure = present + $source = 'absent', + $ensure = present ){ + if $::hardwaremodel == 'x86_64' and $::operatingsystem != 'debian' { + $real_path = "/usr/lib64/nagios/plugins/${name}" + } + else { + $real_path = "/usr/lib/nagios/plugins/${name}" + } + + $real_source = $source ? { + 'absent' => "puppet:///modules/nagios/plugins/${name}", + default => "puppet:///modules/${source}" + } + file{$name: - path => $::hardwaremodel ? { - 'x86_64' => "/usr/lib64/nagios/plugins/${name}", - default => "/usr/lib/nagios/plugins/${name}", - }, - ensure => $ensure, - source => $source ? { - 'absent' => "puppet:///modules/nagios/plugins/${name}", - default => "puppet:///modules/${source}" - }, - tag => 'nagios_plugin', + ensure => $ensure, + path => $real_path, + source => $real_source, + tag => 'nagios_plugin', require => Package['nagios-plugins'], - owner => root, group => 0, mode => 0755; + owner => 'root', + group => 0, + mode => '0755'; } } diff --git a/manifests/service.pp b/manifests/service.pp index c214d7e..9e265a6 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -27,7 +27,7 @@ define nagios::service ( } if $ensure != 'absent' { - if $check_comand == 'absent' { + if $check_command == 'absent' { fail("Must pass a check_command to ${name} if it should be present") } if $use_nrpe == true { diff --git a/manifests/target.pp b/manifests/target.pp index aaa67cf..40ff18a 100644 --- a/manifests/target.pp +++ b/manifests/target.pp @@ -3,14 +3,20 @@ class nagios::target( $parents = 'absent', $address = $::ipaddress, - $nagios_alias = $::hostname, + $nagios_alias = $::false, $hostgroups = 'absent', $notes = 'absent' ){ @@nagios_host { $::fqdn: address => $address, - alias => $nagios_alias, - use => 'generic-host', + use => 'generic-host', + } + # Watch out with using aliases: they need to be unique throughout *all* + # resources in a given host's catalogue. + if $nagios_alias { + Nagios_host[$::fqdn] { + alias => $nagios_alias, + } } if ($parents != 'absent') { |