summaryrefslogtreecommitdiff
path: root/puppet/modules
diff options
context:
space:
mode:
Diffstat (limited to 'puppet/modules')
-rw-r--r--puppet/modules/site_nagios/manifests/add_host.pp29
-rw-r--r--puppet/modules/site_nagios/manifests/add_service.pp22
-rw-r--r--puppet/modules/site_nagios/manifests/server.pp3
3 files changed, 26 insertions, 28 deletions
diff --git a/puppet/modules/site_nagios/manifests/add_host.pp b/puppet/modules/site_nagios/manifests/add_host.pp
index 5148048d..d5aac67c 100644
--- a/puppet/modules/site_nagios/manifests/add_host.pp
+++ b/puppet/modules/site_nagios/manifests/add_host.pp
@@ -1,30 +1,29 @@
-define site_nagios::add_host ($ip, $services='' ) {
-
- $nagios_hostname = $name
-
- #notice ("$nagios_hostname $ip $services")
+define site_nagios::add_host {
+ $nagios_host = $name
+ $nagios_hostname = $name['domain_full']
+ $nagios_ip = $name['ip_address']
+ $nagios_services = $name['services']
+ # Add Nagios host
nagios_host { $nagios_hostname:
- address => $ip,
+ address => $nagios_ip,
use => 'generic-host',
}
- # turn serice array into hash
- # https://github.com/ashak/puppet-resource-looping
+ # Add Nagios service
+
+ # First, we need to turn the serice array into hash, using a "hash template"
+ # see https://github.com/ashak/puppet-resource-looping
$nagios_service_hashpart = {
- 'host' => $nagios_hostname,
- 'ip' => $ip,
+ 'hostname' => $nagios_hostname,
+ 'ip_address' => $nagios_ip,
}
$dynamic_parameters = {
'service' => '%s'
}
-
- #$nagios_services = ['one', 'two']
$nagios_servicename = "${nagios_hostname}_%s"
- $nagios_service_hash = create_resources_hash_from($nagios_servicename, $services, $nagios_service_hashpart, $dynamic_parameters)
- #notice ($created_resource_hash)
-
+ $nagios_service_hash = create_resources_hash_from($nagios_servicename, $nagios_services, $nagios_service_hashpart, $dynamic_parameters)
create_resources ( site_nagios::add_service, $nagios_service_hash )
}
diff --git a/puppet/modules/site_nagios/manifests/add_service.pp b/puppet/modules/site_nagios/manifests/add_service.pp
index 5a5b344f..1a69e068 100644
--- a/puppet/modules/site_nagios/manifests/add_service.pp
+++ b/puppet/modules/site_nagios/manifests/add_service.pp
@@ -1,22 +1,22 @@
-define site_nagios::add_service ($host, $ip, $service) {
-
- notice ('$name $host $ip $service')
+define site_nagios::add_service ($hostname, $ip_address, $service) {
case $service {
'openvpn': {
- $check_command = 'check_openvpn!...'
+ $check_command = 'check_openvpn'
$service_description = 'Openvpn'
}
'webapp': {
- $check_command = 'check_http!...'
+ $check_command = 'check_http'
$service_description = 'Website'
}
- default: { fail ('unknown service') }
+ default: { notice ("No Nagios service check for service \"$service\"") }
}
- nagios_service { $name:
- use => 'generic-service',
- check_command => $check_command,
- service_description => $service_description,
- host_name => $host }
+ if ( $check_command != '' ) {
+ nagios_service { $name:
+ use => 'generic-service',
+ check_command => $check_command,
+ service_description => $service_description,
+ host_name => $hostname }
+ }
}
diff --git a/puppet/modules/site_nagios/manifests/server.pp b/puppet/modules/site_nagios/manifests/server.pp
index df3e00cd..a8ebeaf4 100644
--- a/puppet/modules/site_nagios/manifests/server.pp
+++ b/puppet/modules/site_nagios/manifests/server.pp
@@ -13,6 +13,5 @@ class site_nagios::server {
#before => Class ['nagios::defaults']
}
- create_resources ( site_nagios::add_host, $hosts)
-
+ site_nagios::add_host {$hosts:}
}