[MediaWiki-commits] [Gerrit] operations/puppet[production]: Revert "Revert "monitoring: Export based on class icinga inc...

2016-10-17 Thread Alexandros Kosiaris (Code Review)
Alexandros Kosiaris has submitted this change and it was merged.

Change subject: Revert "Revert "monitoring: Export based on class icinga 
inclusion""
..


Revert "Revert "monitoring: Export based on class icinga inclusion""

Fixes:
* Remove the target parameter from both monitoring::host and
monitoring::service. In production this has not been used in a very long
time due to the exported nature of ALL resources and naggen2. Using the
defaults actually sounds sane in this case, mostly due to the very small
number of resources this is expected to run for.
* Fix the logic of the if clause. It was the exact opposite of what it
should have been

This reverts commit f2a9242a0c8ea310d29306c4578339cef4658214.

Change-Id: I6197102e3a89201ee661a30be905728c7132b1cc
---
M modules/icinga/templates/icinga.cfg.erb
M modules/monitoring/manifests/host.pp
M modules/monitoring/manifests/service.pp
3 files changed, 15 insertions(+), 11 deletions(-)

Approvals:
  Alexandros Kosiaris: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/icinga/templates/icinga.cfg.erb 
b/modules/icinga/templates/icinga.cfg.erb
index 6ec5252..dff6a84 100644
--- a/modules/icinga/templates/icinga.cfg.erb
+++ b/modules/icinga/templates/icinga.cfg.erb
@@ -36,6 +36,7 @@
 cfg_file=/etc/icinga/contacts.cfg
 cfg_file=/etc/icinga/timeperiods.cfg
 cfg_file=/etc/icinga/notification_commands.cfg
+# We use naggen2 for those
 cfg_file=/etc/icinga/puppet_hosts.cfg
 cfg_file=/etc/icinga/puppet_hostextinfo.cfg
 cfg_file=/etc/icinga/puppet_services.cfg
@@ -48,6 +49,9 @@
 # backwards compatibility with old nagios installation
 cfg_file=/etc/nagios/puppet_hostgroups.cfg
 cfg_file=/etc/nagios/puppet_servicegroups.cfg
+# These are locally generated hosts (like routers, pdus). We do not use 
naggen2 for these
+cfg_file=/etc/nagios/nagios_host.cfg
+cfg_file=/etc/nagios/nagios_service.cfg
 
 # passive checks via nsca from fundraising systems
 cfg_file=/etc/icinga/nsca_frack.cfg
diff --git a/modules/monitoring/manifests/host.pp 
b/modules/monitoring/manifests/host.pp
index 585dab7..7764c9a 100644
--- a/modules/monitoring/manifests/host.pp
+++ b/modules/monitoring/manifests/host.pp
@@ -7,7 +7,6 @@
 $group = undef,
 $ensure= present,
 $critical  = false,
-$exported  = true,
 $contact_group = hiera('contactgroups', 'admins')
 ) {
 
@@ -51,7 +50,6 @@
 $host = {
 "${title}" => {
 ensure=> $ensure,
-target=> '/etc/nagios/puppet_hosts.cfg',
 host_name => $title,
 address   => $nagios_address,
 hostgroups=> $hostgroup,
@@ -67,9 +65,11 @@
 statusmap_image   => $statusmap_image,
 }
 }
-if $exported {
-create_resources('@@nagios_host', $host)
-} else {
+# This is a hack. We detect if we are running on the scope of an icinga
+# host and avoid exporting the resource if yes
+if defined(Class['icinga']) {
 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 39a540b..b85e85b 100644
--- a/modules/monitoring/manifests/service.pp
+++ b/modules/monitoring/manifests/service.pp
@@ -7,7 +7,6 @@
 $ensure= present,
 $critical  = false,
 $passive   = false,
-$exported  = true,
 $freshness = 36000,
 $normal_check_interval = 1,
 $retry_check_interval  = 1,
@@ -71,11 +70,10 @@
 default => undef,
 }
 
-# Export the nagios service instance
+# the nagios service instance
 $service = {
 "${::hostname} ${title}" => {
 ensure => $ensure,
-target => 
"${config_dir}/puppet_checks.d/${host}.cfg",
 host_name  => $host,
 servicegroups  => $servicegroups,
 service_description=> $description_safe,
@@ -95,9 +93,11 @@
 freshness_threshold=> $is_fresh,
 }
 }
-if $exported {
-create_resources('@@nagios_service', $service)
-} else {
+# This is a hack. We detect if we are running on the scope of an icinga
+# host and avoid exporting the resource if yes
+if defined(Class['icinga']) {
 create_resources(nagios_service, $service)
+} else {
+create_resources('@@nagios_service', $service)
 }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6197102e3a89201ee661a30be905728c7132b1cc
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alexandros Kosiaris 
Gerr

[MediaWiki-commits] [Gerrit] operations/puppet[production]: Revert "Revert "monitoring: Export based on class icinga inc...

2016-10-17 Thread Alexandros Kosiaris (Code Review)
Alexandros Kosiaris has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316333

Change subject: Revert "Revert "monitoring: Export based on class icinga 
inclusion""
..

Revert "Revert "monitoring: Export based on class icinga inclusion""

Fixes:
* Remove the target parameter from both monitoring::host and
monitoring::service. In production this has not been used in a very long
time due to the exported nature of ALL resources and naggen2. Using the
defaults actually sounds sane in this case, mostly due to the very small
number of resources this is expected to run for.
* Fix the logic of the if clause. It was the exact opposite of what it
should have been

This reverts commit f2a9242a0c8ea310d29306c4578339cef4658214.

Change-Id: I6197102e3a89201ee661a30be905728c7132b1cc
---
M modules/icinga/templates/icinga.cfg.erb
M modules/monitoring/manifests/host.pp
M modules/monitoring/manifests/service.pp
3 files changed, 15 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/33/316333/1

diff --git a/modules/icinga/templates/icinga.cfg.erb 
b/modules/icinga/templates/icinga.cfg.erb
index 6ec5252..dff6a84 100644
--- a/modules/icinga/templates/icinga.cfg.erb
+++ b/modules/icinga/templates/icinga.cfg.erb
@@ -36,6 +36,7 @@
 cfg_file=/etc/icinga/contacts.cfg
 cfg_file=/etc/icinga/timeperiods.cfg
 cfg_file=/etc/icinga/notification_commands.cfg
+# We use naggen2 for those
 cfg_file=/etc/icinga/puppet_hosts.cfg
 cfg_file=/etc/icinga/puppet_hostextinfo.cfg
 cfg_file=/etc/icinga/puppet_services.cfg
@@ -48,6 +49,9 @@
 # backwards compatibility with old nagios installation
 cfg_file=/etc/nagios/puppet_hostgroups.cfg
 cfg_file=/etc/nagios/puppet_servicegroups.cfg
+# These are locally generated hosts (like routers, pdus). We do not use 
naggen2 for these
+cfg_file=/etc/nagios/nagios_host.cfg
+cfg_file=/etc/nagios/nagios_service.cfg
 
 # passive checks via nsca from fundraising systems
 cfg_file=/etc/icinga/nsca_frack.cfg
diff --git a/modules/monitoring/manifests/host.pp 
b/modules/monitoring/manifests/host.pp
index 585dab7..7764c9a 100644
--- a/modules/monitoring/manifests/host.pp
+++ b/modules/monitoring/manifests/host.pp
@@ -7,7 +7,6 @@
 $group = undef,
 $ensure= present,
 $critical  = false,
-$exported  = true,
 $contact_group = hiera('contactgroups', 'admins')
 ) {
 
@@ -51,7 +50,6 @@
 $host = {
 "${title}" => {
 ensure=> $ensure,
-target=> '/etc/nagios/puppet_hosts.cfg',
 host_name => $title,
 address   => $nagios_address,
 hostgroups=> $hostgroup,
@@ -67,9 +65,11 @@
 statusmap_image   => $statusmap_image,
 }
 }
-if $exported {
-create_resources('@@nagios_host', $host)
-} else {
+# This is a hack. We detect if we are running on the scope of an icinga
+# host and avoid exporting the resource if yes
+if defined(Class['icinga']) {
 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 39a540b..b85e85b 100644
--- a/modules/monitoring/manifests/service.pp
+++ b/modules/monitoring/manifests/service.pp
@@ -7,7 +7,6 @@
 $ensure= present,
 $critical  = false,
 $passive   = false,
-$exported  = true,
 $freshness = 36000,
 $normal_check_interval = 1,
 $retry_check_interval  = 1,
@@ -71,11 +70,10 @@
 default => undef,
 }
 
-# Export the nagios service instance
+# the nagios service instance
 $service = {
 "${::hostname} ${title}" => {
 ensure => $ensure,
-target => 
"${config_dir}/puppet_checks.d/${host}.cfg",
 host_name  => $host,
 servicegroups  => $servicegroups,
 service_description=> $description_safe,
@@ -95,9 +93,11 @@
 freshness_threshold=> $is_fresh,
 }
 }
-if $exported {
-create_resources('@@nagios_service', $service)
-} else {
+# This is a hack. We detect if we are running on the scope of an icinga
+# host and avoid exporting the resource if yes
+if defined(Class['icinga']) {
 create_resources(nagios_service, $service)
+} else {
+create_resources('@@nagios_service', $service)
 }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6197102e3a89201ee661a30be905728c7132b1cc
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
G