Alexandros Kosiaris has submitted this change and it was merged.

Change subject: monitoring: Add an exported parameter to host, service
......................................................................


monitoring: Add an exported parameter to host, service

Having by definition monitoring::service and monitoring::host exporting
their resources is not very user friendly. It also adds unnecessary
latency to the icinga server catalog compilation and means that locally
defined hosts and services will be stored in the storedconfigs database
for no reason. Add a parameter called exported, defaulting to true to
maintain compatibility, that allows to define whether we want the
resource to be exported or not

Change-Id: I2b9b15cd1d8174171b3ef3d271ee38c3b844d7e0
---
M modules/monitoring/manifests/host.pp
M modules/monitoring/manifests/service.pp
2 files changed, 52 insertions(+), 36 deletions(-)

Approvals:
  Alexandros Kosiaris: Verified; Looks good to me, approved



diff --git a/modules/monitoring/manifests/host.pp 
b/modules/monitoring/manifests/host.pp
index 0ae3a35..585dab7 100644
--- a/modules/monitoring/manifests/host.pp
+++ b/modules/monitoring/manifests/host.pp
@@ -7,6 +7,7 @@
     $group         = undef,
     $ensure        = present,
     $critical      = false,
+    $exported      = true,
     $contact_group = hiera('contactgroups', 'admins')
     ) {
 
@@ -47,21 +48,28 @@
         $vrml_image      = undef
         $statusmap_image = undef
     }
-    @@nagios_host { $title:
-        ensure                => $ensure,
-        target                => '/etc/nagios/puppet_hosts.cfg',
-        host_name             => $title,
-        address               => $nagios_address,
-        hostgroups            => $hostgroup,
-        check_command         => 'check_ping!500,20%!2000,100%',
-        check_period          => '24x7',
-        max_check_attempts    => 2,
-        contact_groups        => $is_critical,
-        notification_interval => 0,
-        notification_period   => '24x7',
-        notification_options  => 'd,u,r,f',
-        icon_image            => $icon_image,
-        vrml_image            => $vrml_image,
-        statusmap_image       => $statusmap_image,
+    $host = {
+        "${title}" => {
+            ensure                => $ensure,
+            target                => '/etc/nagios/puppet_hosts.cfg',
+            host_name             => $title,
+            address               => $nagios_address,
+            hostgroups            => $hostgroup,
+            check_command         => 'check_ping!500,20%!2000,100%',
+            check_period          => '24x7',
+            max_check_attempts    => 2,
+            contact_groups        => $is_critical,
+            notification_interval => 0,
+            notification_period   => '24x7',
+            notification_options  => 'd,u,r,f',
+            icon_image            => $icon_image,
+            vrml_image            => $vrml_image,
+            statusmap_image       => $statusmap_image,
+        }
+    }
+    if $exported {
+        create_resources('@@nagios_host', $host)
+    } else {
+        create_resources(nagios_host, $host)
     }
 }
diff --git a/modules/monitoring/manifests/service.pp 
b/modules/monitoring/manifests/service.pp
index 5c001a3..39a540b 100644
--- a/modules/monitoring/manifests/service.pp
+++ b/modules/monitoring/manifests/service.pp
@@ -7,6 +7,7 @@
     $ensure                = present,
     $critical              = false,
     $passive               = false,
+    $exported              = true,
     $freshness             = 36000,
     $normal_check_interval = 1,
     $retry_check_interval  = 1,
@@ -71,25 +72,32 @@
     }
 
     # Export the nagios service instance
-    @@nagios_service { "${::hostname} ${title}":
-        ensure                 => $ensure,
-        target                 => "${config_dir}/puppet_checks.d/${host}.cfg",
-        host_name              => $host,
-        servicegroups          => $servicegroups,
-        service_description    => $description_safe,
-        check_command          => $check_command,
-        max_check_attempts     => $retries,
-        normal_check_interval  => $normal_check_interval,
-        retry_check_interval   => $retry_check_interval,
-        check_period           => '24x7',
-        notification_interval  => $notification_critical,
-        notification_period    => '24x7',
-        notification_options   => 'c,r,f',
-        contact_groups         => $contact_critical,
-        passive_checks_enabled => 1,
-        active_checks_enabled  => $is_active,
-        is_volatile            => $check_volatile,
-        check_freshness        => $check_fresh,
-        freshness_threshold    => $is_fresh,
+    $service = {
+        "${::hostname} ${title}" => {
+            ensure                 => $ensure,
+            target                 => 
"${config_dir}/puppet_checks.d/${host}.cfg",
+            host_name              => $host,
+            servicegroups          => $servicegroups,
+            service_description    => $description_safe,
+            check_command          => $check_command,
+            max_check_attempts     => $retries,
+            normal_check_interval  => $normal_check_interval,
+            retry_check_interval   => $retry_check_interval,
+            check_period           => '24x7',
+            notification_interval  => $notification_critical,
+            notification_period    => '24x7',
+            notification_options   => 'c,r,f',
+            contact_groups         => $contact_critical,
+            passive_checks_enabled => 1,
+            active_checks_enabled  => $is_active,
+            is_volatile            => $check_volatile,
+            check_freshness        => $check_fresh,
+            freshness_threshold    => $is_fresh,
+        }
+    }
+    if $exported {
+        create_resources('@@nagios_service', $service)
+    } else {
+        create_resources(nagios_service, $service)
     }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/315500
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2b9b15cd1d8174171b3ef3d271ee38c3b844d7e0
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alexandros Kosiaris <akosia...@wikimedia.org>
Gerrit-Reviewer: Alexandros Kosiaris <akosia...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to