Faidon Liambotis has submitted this change and it was merged.
Change subject: Add librenms module and role class & apply it
......................................................................
Add librenms module and role class & apply it
LibreNMS is a GPL Observium fork. Sets up Apache, user accounts, cron
jobs and provisions via Trebuchet from an internal git mirror.
Change-Id: I61073f915b8c5a5b26b28c60b6888563a268c6b1
---
M manifests/role/deployment.pp
A manifests/role/librenms.pp
M manifests/site.pp
A modules/librenms/files/logrotate
A modules/librenms/lib/puppet/parser/functions/phpdump.rb
A modules/librenms/manifests/init.pp
A modules/librenms/templates/config.php.erb
7 files changed, 223 insertions(+), 1 deletion(-)
Approvals:
Faidon Liambotis: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/manifests/role/deployment.pp b/manifests/role/deployment.pp
index 6d32a44..784048a 100644
--- a/manifests/role/deployment.pp
+++ b/manifests/role/deployment.pp
@@ -133,6 +133,10 @@
'grain' => 'scholarships',
'upstream' =>
'https://gerrit.wikimedia.org/r/wikimedia/wikimania-scholarships',
},
+ 'librenms/librenms' => {
+ 'grain' => 'librenms',
+ 'upstream' =>
'https://gerrit.wikimedia.org/r/operations/software/librenms',
+ },
}
}
diff --git a/manifests/role/librenms.pp b/manifests/role/librenms.pp
new file mode 100644
index 0000000..3c1b637
--- /dev/null
+++ b/manifests/role/librenms.pp
@@ -0,0 +1,70 @@
+class role::librenms {
+ system::role { 'librenms': description => 'LibreNMS' }
+
+ include network::constants
+ include passwords::librenms
+ include passwords::network
+
+ $sitename = 'librenms.wikimedia.org'
+
+ deployment::target { 'librenms': }
+ $install_dir = '/srv/deployment/librenms/librenms'
+
+ $config = {
+ 'install_dir' => $install_dir,
+ 'html_dir' => "${install_dir}/html",
+ 'log_file' => '/var/log/librenms.log',
+ 'rrd_dir' => '/var/lib/librenms/rrd',
+
+ 'db_host' => 'db1001.eqiad.wmnet',
+ 'db_user' => $passwords::librenms::db_user,
+ 'db_pass' => $passwords::librenms::db_pass,
+ 'db_name' => 'librenms',
+
+ 'snmp' => {
+ 'community' => [ $passwords::network::snmp_ro_community ],
+ },
+
+ 'enable_inventory' => 1,
+ 'enable_syslog' => 1,
+ 'email_backend' => 'sendmail',
+ 'alerts' => {
+ 'port_util_alert' => true,
+ 'port_util_perc' => 85,
+ 'email' => {
+ 'default' => '[email protected]',
+ 'enable' => true,
+ },
+ 'port' => {
+ 'ifdown' => false,
+ },
+ },
+
+ 'auth_mechanism' => 'mysql',
+ 'nets' => $network::constants::external_networks,
+ }
+
+ class { 'librenms':
+ install_dir => $install_dir,
+ config => $config,
+ }
+
+ @webserver::apache::module { 'php5': }
+ @webserver::apache::site { $sitename:
+ docroot => $install_dir,
+ require => [
+ Webserver::Apache::Module['php5'],
+ Class['librenms'],
+ ],
+ }
+
+ # redirect the old, pre-Jan 2014 name to librenms
+ @webserver::apache::site { 'observium.wikimedia.org':
+ custom => [ "Redirect permanent / https://${sitename}/" ],
+ }
+
+ monitor_service { 'librenms':
+ description => 'HTTP',
+ check_command => "check_http_url!${sitename}!http://${sitename}",
+ }
+}
diff --git a/manifests/site.pp b/manifests/site.pp
index 66b3b26..0298010 100644
--- a/manifests/site.pp
+++ b/manifests/site.pp
@@ -1891,7 +1891,8 @@
webserver::apache,
misc::rancid,
smokeping,
- smokeping::web
+ smokeping::web,
+ role::librenms
}
node /^nfs[12].pmtpa.wmnet/ {
diff --git a/modules/librenms/files/logrotate b/modules/librenms/files/logrotate
new file mode 100644
index 0000000..8766aa7
--- /dev/null
+++ b/modules/librenms/files/logrotate
@@ -0,0 +1,6 @@
+/var/log/librenms.log {
+ rotate 7
+ daily
+ compress
+ missingok
+}
diff --git a/modules/librenms/lib/puppet/parser/functions/phpdump.rb
b/modules/librenms/lib/puppet/parser/functions/phpdump.rb
new file mode 100644
index 0000000..2033613
--- /dev/null
+++ b/modules/librenms/lib/puppet/parser/functions/phpdump.rb
@@ -0,0 +1,34 @@
+# == Function: phpdump
+#
+# Serialize a hash into PHP array with lexicographically sorted keys.
+#
+
+def phpdump(o, level=1)
+ indent = " "*4
+
+ case o
+ when Hash
+ contents = ''
+ o.sort.each do |k, v|
+ contents += indent*level
+ contents += "\"#{k}\" => " + phpdump(v, level+1)
+ contents += ",\n"
+ end
+ "array(\n" + contents + indent*(level-1) + ")"
+ when Array
+ "array(" + o.map { |x| phpdump(x, level+1) }.join(', ') + ")"
+ when TrueClass
+ "TRUE"
+ when FalseClass
+ "FALSE"
+ else
+ '"' + o.to_s + '"'
+ end
+end
+
+module Puppet::Parser::Functions
+ newfunction(:phpdump, :type => :rvalue) do |args|
+ fail 'phpdump() requires an argument' if args.empty?
+ phpdump(args.inject(:merge))
+ end
+end
diff --git a/modules/librenms/manifests/init.pp
b/modules/librenms/manifests/init.pp
new file mode 100644
index 0000000..7f106bc
--- /dev/null
+++ b/modules/librenms/manifests/init.pp
@@ -0,0 +1,101 @@
+# == Class: librenms
+#
+# This class installs & manages LibreNMS, a fork of Observium
+#
+# == Parameters
+#
+# [*config*]
+# Configuration for LibreNMS, in a puppet hash format.
+#
+# [*install_dir*]
+# Installation directory for LibreNMS.
+#
+class librenms(
+ $config,
+ $install_dir='/srv/librenms',
+) {
+ group { 'librenms':
+ ensure => present,
+ }
+
+ user { 'librenms':
+ ensure => present,
+ gid => 'librenms',
+ shell => '/bin/false',
+ home => '/nonexistent',
+ system => true,
+ managehome => false,
+ }
+
+ file { $install_dir:
+ ensure => directory,
+ owner => 'www-data',
+ group => 'librenms',
+ mode => '0555',
+ require => Group['librenms'],
+ }
+
+ file { "${install_dir}/config.php":
+ ensure => present,
+ owner => 'www-data',
+ group => 'librenms',
+ mode => '0440',
+ content => template('librenms/config.php.erb'),
+ require => Group['librenms'],
+ }
+
+ file { '/var/lib/librenms/rrd':
+ ensure => directory,
+ owner => 'librenms',
+ group => 'librenms',
+ mode => '0555',
+ }
+
+ file { '/etc/logrotate.d/librenms':
+ ensure => present,
+ owner => 'root',
+ group => 'root',
+ source => 'puppet:///modules/librenms/logrotate',
+ }
+
+ package { [
+ 'php5-cli',
+ 'php5-gd',
+ 'php5-json',
+ 'php5-mcrypt',
+ 'php5-mysql',
+ 'php5-snmp',
+ 'php-pear',
+ 'fping',
+ 'graphviz',
+ 'imagemagick',
+ 'ipmitool',
+ 'mtr-tiny',
+ 'nmap',
+ 'python-mysqldb',
+ 'rrdtool',
+ 'whois',
+ ]:
+ ensure => present,
+ }
+
+ cron { 'librenms-discovery-all':
+ ensure => present,
+ user => 'librenms',
+ command => "${install_dir}/discovery.php -h all >> /dev/null 2>&1",
+ hour => '*/6',
+ minute => '33',
+ }
+ cron { 'librenms-discovery-new':
+ ensure => present,
+ user => 'librenms',
+ command => "${install_dir}/discovery.php -h all >> /dev/null 2>&1",
+ minute => '*/5',
+ }
+ cron { 'librenms-poller-all':
+ ensure => present,
+ user => 'librenms',
+ command => "${install_dir}/poller.php -h all >> /dev/null 2>&1",
+ minute => '*/5',
+ }
+}
diff --git a/modules/librenms/templates/config.php.erb
b/modules/librenms/templates/config.php.erb
new file mode 100644
index 0000000..b65bc2f
--- /dev/null
+++ b/modules/librenms/templates/config.php.erb
@@ -0,0 +1,6 @@
+<?php
+# This file is managed by Puppet!
+
+$config = <%= scope.function_phpdump(@config) %>;
+
+?>
--
To view, visit https://gerrit.wikimedia.org/r/106694
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I61073f915b8c5a5b26b28c60b6888563a268c6b1
Gerrit-PatchSet: 6
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <[email protected]>
Gerrit-Reviewer: Faidon Liambotis <[email protected]>
Gerrit-Reviewer: Mark Bergsma <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits