mirror of
https://github.com/zulip/zulip.git
synced 2025-10-28 02:23:57 +00:00
puppet: Pull hosts from zulip.conf, not hardcoded list.
The one complexity is that hosts_fullstack are treated differently, as they are not currently found in the manual `hosts` list, and as such do not get munin monitoring.
This commit is contained in:
committed by
Tim Abbott
parent
24383a5082
commit
8cff27f67d
@@ -10,4 +10,26 @@ module Puppet::Parser::Functions
|
||||
default
|
||||
end
|
||||
end
|
||||
|
||||
newfunction(:zulipconf_nagios_hosts, :type => :rvalue, :arity => 0) do |args|
|
||||
section = "nagios"
|
||||
prefix = "hosts_"
|
||||
ignore_key = "hosts_fullstack"
|
||||
zulip_conf_path = lookupvar('zulip_conf_path')
|
||||
keys = `/usr/bin/crudini --get #{zulip_conf_path} #{section} 2>&1`; result=$?.success?
|
||||
if result
|
||||
keys = keys.lines.map { |l| l.strip }
|
||||
filtered_keys = keys.select { |l| l.start_with?(prefix) }.reject { |k| k == ignore_key }
|
||||
all_values = []
|
||||
filtered_keys.each do |key|
|
||||
values = `/usr/bin/crudini --get #{zulip_conf_path} #{section} #{key} 2>&1`; result=$?.success?
|
||||
if result
|
||||
all_values += values.strip.split(/,\s*/)
|
||||
end
|
||||
end
|
||||
return all_values
|
||||
else
|
||||
return []
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,9 +36,6 @@ class zulip_ops::base {
|
||||
# Add system users here
|
||||
$users = []
|
||||
|
||||
# Add hosts to monitor here
|
||||
$hosts = []
|
||||
|
||||
file { '/etc/apt/apt.conf.d/02periodic':
|
||||
ensure => file,
|
||||
mode => '0644',
|
||||
|
||||
@@ -10,7 +10,7 @@ class zulip_ops::munin {
|
||||
package { $munin_packages: ensure => 'installed' }
|
||||
|
||||
$default_host_domain = zulipconf('nagios', 'default_host_domain', undef)
|
||||
$hosts = $zulip_ops::base::hosts
|
||||
$hosts = zulipconf_nagios_hosts()
|
||||
|
||||
file { '/etc/munin':
|
||||
require => Package['munin'],
|
||||
|
||||
@@ -105,7 +105,7 @@ class zulip_ops::nagios {
|
||||
notify => Service['nagios3'],
|
||||
}
|
||||
|
||||
$hosts = $zulip_ops::base::hosts
|
||||
$hosts = zulipconf_nagios_hosts()
|
||||
file { '/etc/nagios3/conf.d/zulip_autossh.cfg':
|
||||
ensure => file,
|
||||
mode => '0644',
|
||||
|
||||
Reference in New Issue
Block a user