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:
Alex Vandiver
2020-07-10 02:24:51 +00:00
committed by Tim Abbott
parent 24383a5082
commit 8cff27f67d
4 changed files with 24 additions and 5 deletions

View File

@@ -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

View File

@@ -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',

View File

@@ -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'],

View File

@@ -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',