summaryrefslogtreecommitdiff
path: root/manifests/service.pp
diff options
context:
space:
mode:
authorJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2009-12-02 19:32:15 -0500
committerJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2009-12-02 19:32:15 -0500
commit1201207f492dd807d754df0d4fc4156384248ebb (patch)
tree5eb04da55fd836a43550dcc4580f2466954b2b0d /manifests/service.pp
parente768ec64081846a5ed091e47ac9b5b79d3893e70 (diff)
refactor service resource without any hardcoded defaults, and use 'generic-service' template by default
Diffstat (limited to 'manifests/service.pp')
-rw-r--r--manifests/service.pp99
1 files changed, 62 insertions, 37 deletions
diff --git a/manifests/service.pp b/manifests/service.pp
index 42d9a4d..1127076 100644
--- a/manifests/service.pp
+++ b/manifests/service.pp
@@ -1,52 +1,77 @@
-define nagios::service(
+define nagios::service (
$ensure = present,
- $check_command,
$host_name = $fqdn,
- $use = 'generic-service',
- $notification_period = "24x7",
- $max_check_attempts = 4,
- $retry_check_interval = 1,
- $notification_interval = 960,
- $normal_check_interval = 5,
- $check_period = "24x7",
- $nagios_contact_groups_in = $nagios_contact_groups,
- $service_description = 'absent')
+ $check_command,
+ $check_period = '',
+ $normal_check_interval = '',
+ $retry_check_interval = '',
+ $max_check_attempts = '',
+ $notification_interval = '',
+ $notification_period = '',
+ $notification_options = '',
+ $contact_groups = '',
+ $use = '',
+ $service_description = '' )
{
- # this ensures nagios internal check, that every
- # service has it's host
- # temporary disabled.
- # include nagios::target::host
+ # TODO: this resource should normally accept all nagios_host parameters
- $real_nagios_contact_groups = $nagios_contact_groups_in ? {
- '' => 'admins',
- default => $nagios_contact_groups_in
- }
- @@nagios_service {$name:
+ $real_name = "${hostname}_${name}"
+
+ @@nagios_service { "${real_name}":
ensure => $ensure,
check_command => $check_command,
- use => $use,
host_name => $host_name,
- notification_period => $notification_period,
- max_check_attempts => $max_check_attempts,
- retry_check_interval => $retry_check_interval,
- notification_interval => $notification_interval,
- normal_check_interval => $normal_check_interval,
- contact_groups => $real_nagios_contact_groups,
- check_period => $check_period,
notify => Service[nagios],
}
- case $service_description {
- 'absent': {
- Nagios_service[$name]{
- service_description => $name,
- }
+
+ if ($check_period != '') {
+ Nagios_service["${real_name}"] { check_period => $check_period }
+ }
+
+ if ($normal_check_interval != '') {
+ Nagios_service["${real_name}"] { normal_check_interval => $normal_check_interval }
+ }
+
+ if ($retry_check_interval != '') {
+ Nagios_service["${real_name}"] { retry_check_interval => $retry_check_interval }
+ }
+
+ if ($max_check_attempts != '') {
+ Nagios_service["${real_name}"] { max_check_attempts => $max_check_attempts }
+ }
+
+ if ($notification_interval != '') {
+ Nagios_service["${real_name}"] { notification_interval => $notification_interval }
+ }
+
+ if ($notification_period != '') {
+ Nagios_service["${real_name}"] { notification_period => $notification_period }
+ }
+
+ if ($notification_options != '') {
+ Nagios_service["${real_name}"] { notification_options => $notification_options }
+ }
+
+ if ($use != '') {
+ Nagios_service["${real_name}"] { use => $use }
+ }
+
+ if ($use != 'absent') {
+ if ($use == '') {
+ Nagios_service["${real_name}"] { use => 'generic-service' }
+ } else {
+ Nagios_service["${real_name}"] { use => $use }
}
- default: {
- Nagios_service[$name]{
- service_description => $service_description,
- }
+ }
+
+ if ($service_description != 'absent') {
+ if ($service_description == '') {
+ Nagios_service["${real_name}"] { service_description => $name }
+ } else {
+ Nagios_service["${real_name}"] { service_description => $service_description }
}
}
+
}