aboutsummaryrefslogblamecommitdiff
path: root/modules/profile/manifests/monitoring/local_service.pp
blob: 1f975f03c26d91038ad4c3341e976a15ff0f1d73 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                           
                              



                              

                                     
                               
 








                                   
                                      



                                                      
   




                                             



                                                                                          
                                                                                   




                             



                                                             











                                                         
define profile::monitoring::local_service (
  Optional[Hash] $sudos  = {},
  Optional[Hash] $common = {},
  Optional[Hash] $master = {},
  Optional[Hash] $local  = {},
) {
  include profile::monitoring::params

  $service_description = $title

  Nagios_service {
    ensure  => "present",
    owner   => "naemon",
    group   => "naemon",
    notify  => Service["naemon"],
    before  => Service["naemon"],
    require => File["/etc/naemon"],
  }

  $sudos.each |$sudo_name, $content| {
    ensure_resource("sudo::conf", $sudo_name, {
      content => $content,
      before  => Nagios_service[$service_description],
    })
  }

  [true, false].each |$services_for_master| {
    if $services_for_master {
      $default_local = {
        mode           => "0644",
        target         => $::profile::monitoring::params::services_for_master,
        check_interval => $::profile::monitoring::params::service_local["check_interval"],
        retry_interval => $::profile::monitoring::params::service_local["retry_interval"],
        host_name      => $::profile::monitoring::params::service_local["host_name"],
        use            => $::profile::monitoring::params::service_types["passive"],
        notify         => [],
      }
      $t = "master - "
      $services_key = $master
    } else {
      $default_local = merge(
        $::profile::monitoring::params::service_local,
        { target => $::profile::monitoring::params::objects }
      )
      $t = ""
      $services_key = $local
    }

    $hash = merge($default_local, $common, $services_key)

    nagios_service { "$t$service_description":
      service_description => $service_description,
      *                   => $hash
    }
  }
}