Dzahn has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/366310 )

Change subject: librenms: active_server param, don't pull data from multi 
servers
......................................................................

librenms: active_server param, don't pull data from multi servers

Add an active_server parameter, just like it was done for rancid.

The same Hiera setting can switch between netmon servers for both
services.

Only run crons on the active server, remove them on inactive server,
as requested by Arzhel we should not pull data for librenms
from multiple netmon servers at the same time.

Bug: T159756
Change-Id: I7f77a255b8feeba4e8b638ffffad565efa651631
---
M modules/librenms/manifests/init.pp
M modules/role/manifests/librenms.pp
2 files changed, 26 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/10/366310/1

diff --git a/modules/librenms/manifests/init.pp 
b/modules/librenms/manifests/init.pp
index 58859fa..ef67063 100644
--- a/modules/librenms/manifests/init.pp
+++ b/modules/librenms/manifests/init.pp
@@ -18,6 +18,7 @@
     $config={},
     $install_dir='/srv/librenms',
     $rrd_dir="${install_dir}/rrd",
+    $active_server,
 ) {
     group { 'librenms':
         ensure => present,
@@ -110,8 +111,14 @@
 
     include ::imagemagick::install
 
+    if $active_server == $::fqdn {
+        $cron_ensure = 'present'
+    } else {
+        $cron_ensure = 'absent'
+    }
+
     cron { 'librenms-discovery-all':
-        ensure  => present,
+        ensure  => $cron_ensure,
         user    => 'librenms',
         command => "${install_dir}/discovery.php -h all >/dev/null 2>&1",
         hour    => '*/6',
@@ -119,49 +126,49 @@
         require => User['librenms'],
     }
     cron { 'librenms-discovery-new':
-        ensure  => present,
+        ensure  => $cron_ensure,
         user    => 'librenms',
         command => "${install_dir}/discovery.php -h new >/dev/null 2>&1",
         minute  => '*/5',
         require => User['librenms'],
     }
     cron { 'librenms-poller-all':
-        ensure  => present,
+        ensure  => $cron_ensure,
         user    => 'librenms',
         command => "python ${install_dir}/poller-wrapper.py 16 >/dev/null 
2>&1",
         minute  => '*/5',
         require => User['librenms'],
     }
     cron { 'librenms-check-services':
-        ensure  => present,
+        ensure  => $cron_ensure,
         user    => 'librenms',
         command => "${install_dir}/check-services.php >/dev/null 2>&1",
         minute  => '*/5',
         require => User['librenms'],
     }
     cron { 'librenms-alerts':
-        ensure  => present,
+        ensure  => $cron_ensure,
         user    => 'librenms',
         command => "${install_dir}/alerts.php >/dev/null 2>&1",
         minute  => '*',
         require => User['librenms'],
     }
     cron { 'librenms-poll-billing':
-        ensure  => present,
+        ensure  => $cron_ensure,
         user    => 'librenms',
         command => "${install_dir}/poll-billing.php >/dev/null 2>&1",
         minute  => '*/5',
         require => User['librenms'],
     }
     cron { 'librenms-billing-calculate':
-        ensure  => present,
+        ensure  => $cron_ensure,
         user    => 'librenms',
         command => "${install_dir}/billing-calculate.php >/dev/null 2>&1",
         minute  => '01',
         require => User['librenms'],
     }
     cron { 'librenms-daily':
-        ensure  => present,
+        ensure  => $cron_ensure,
         user    => 'librenms',
         command => "${install_dir}/daily.sh >/dev/null 2>&1",
         hour    => '0',
@@ -183,7 +190,7 @@
         source => 'puppet:///modules/librenms/purge.py',
     }
     cron { 'purge-syslog-eventlog':
-        ensure  => present,
+        ensure  => $cron_ensure,
         user    => 'librenms',
         command => "python ${install_dir}/purge.py --syslog --eventlog 
--perftimes '1 month' >/dev/null 2>&1",
         hour    => '0',
diff --git a/modules/role/manifests/librenms.pp 
b/modules/role/manifests/librenms.pp
index d394d20..065fa0c 100644
--- a/modules/role/manifests/librenms.pp
+++ b/modules/role/manifests/librenms.pp
@@ -9,6 +9,11 @@
     $sitename = 'librenms.wikimedia.org'
     $install_dir = '/srv/deployment/librenms/librenms'
 
+    # Which of the netmon servers should actually poll data and
+    # have active cron jobs. We don't want both to do it at the same time.
+    # Switch it in hieradata/common.yaml, the default is just a fallback.
+    $active_server = hiera('netmon_server', 'netmon1002.wikimedia.org')
+
     # NOTE: scap will manage the deploy user
     scap::target { 'librenms/librenms':
         deploy_user => 'deploy-librenms',
@@ -111,10 +116,11 @@
     }
 
     class { '::librenms':
-        install_dir => $install_dir,
-        rrd_dir     => '/srv/librenms/rrd',
-        config      => $config,
-        require     => Package['librenms/librenms'],
+        install_dir   => $install_dir,
+        rrd_dir       => '/srv/librenms/rrd',
+        config        => $config,
+        require       => Package['librenms/librenms'],
+        active_server => $active_server,
     }
     class { '::librenms::syslog':
         require => Class['::librenms']

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f77a255b8feeba4e8b638ffffad565efa651631
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Dzahn <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to