Faidon Liambotis has uploaded a new change for review. https://gerrit.wikimedia.org/r/106896
Change subject: librenms: make main class' "config" option simpler ...................................................................... librenms: make main class' "config" option simpler Supplying install_dir, html_dir, rrd_dir & log file to the config hash is kind of wrong, as it's not KISS: the class already knows the best position for these and sets up other stuff based on these locations (e.g. logrotate). Pass them to the config.php template instead, outside of the config hash and simplify the caller. Change-Id: I6620ff7bb206d8fee4fb18607930195382611ec9 --- M manifests/role/librenms.pp M modules/librenms/manifests/init.pp M modules/librenms/templates/config.php.erb 3 files changed, 21 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/96/106896/1 diff --git a/manifests/role/librenms.pp b/manifests/role/librenms.pp index f34bb0a..a67ee50 100644 --- a/manifests/role/librenms.pp +++ b/manifests/role/librenms.pp @@ -21,11 +21,6 @@ $config = { 'title_image' => 'url(//upload.wikimedia.org/wikipedia/commons/thumb/c/c4/Wikimedia_Foundation_RGB_logo_with_text.svg/100px-Wikimedia_Foundation_RGB_logo_with_text.svg.png)', - 'install_dir' => $install_dir, - 'html_dir' => "${install_dir}/html", - 'rrd_dir' => '/srv/librenms/rrd', - 'log_file' => '/var/log/librenms.log', - 'db_host' => 'db1001.eqiad.wmnet', 'db_user' => $passwords::librenms::db_user, 'db_pass' => $passwords::librenms::db_pass, @@ -72,6 +67,7 @@ class { '::librenms': install_dir => $install_dir, + rrd_dir => '/srv/librenms/rrd', config => $config, } class { '::librenms::syslog': diff --git a/modules/librenms/manifests/init.pp b/modules/librenms/manifests/init.pp index 24c3364..0340bc8 100644 --- a/modules/librenms/manifests/init.pp +++ b/modules/librenms/manifests/init.pp @@ -8,11 +8,16 @@ # Configuration for LibreNMS, in a puppet hash format. # # [*install_dir*] -# Installation directory for LibreNMS. +# Installation directory for LibreNMS. Defaults to /srv/librenms. +# +# [*rrd_dir*] +# Location where RRD files are going to be placed. Defaults to "rrd" under +# *install_dir*. # class librenms( - $config, + $config={}, $install_dir='/srv/librenms', + $rrd_dir="${install_dir}/rrd", ) { group { 'librenms': ensure => present, @@ -68,6 +73,7 @@ 'nmap', 'python-mysqldb', 'rrdtool', + #'snmp', 'snmp-mibs-downloader', 'whois', ]: @@ -77,7 +83,7 @@ cron { 'librenms-discovery-all': ensure => present, user => 'librenms', - command => "${install_dir}/discovery.php -h all >> /dev/null 2>&1", + command => "${install_dir}/discovery.php -h all >/dev/null 2>&1", hour => '*/6', minute => '33', require => User['librenms'], @@ -85,18 +91,20 @@ cron { 'librenms-discovery-new': ensure => present, user => 'librenms', - command => "${install_dir}/discovery.php -h new >> /dev/null 2>&1", + command => "${install_dir}/discovery.php -h new >/dev/null 2>&1", minute => '*/5', require => User['librenms'], } cron { 'librenms-poller-all': ensure => present, user => 'librenms', - command => "/usr/bin/python ${install_dir}/poller-wrapper.py 16 >> /dev/null 2>&1", + command => "python ${install_dir}/poller-wrapper.py 16 >/dev/null 2>&1", minute => '*/5', require => User['librenms'], } + # syslog script, in an install_dir-agnostic location + # used by librenms::syslog or a custom alternative placed manually. file { '/usr/local/sbin/librenms-syslog': ensure => link, target => "${install_dir}/syslog.php", diff --git a/modules/librenms/templates/config.php.erb b/modules/librenms/templates/config.php.erb index 49a14a6..ea9dbac 100644 --- a/modules/librenms/templates/config.php.erb +++ b/modules/librenms/templates/config.php.erb @@ -1,5 +1,11 @@ <?php -# This file is managed by Puppet! + +# This file is managed by Puppet, do not modify manually. + +$config['install_dir'] = "<%= @install_dir %>"; +$config['html_dir'] = "<%= @install_dir %>/html"; +$config['rrd_dir'] = "<%= @rrd_dir %>"; +$config['log_file'] = "/var/log/librenms.log"; $puppet_config = <%= scope.function_phpdump(@config) %>; -- To view, visit https://gerrit.wikimedia.org/r/106896 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6620ff7bb206d8fee4fb18607930195382611ec9 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Faidon Liambotis <fai...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits