We have a puppet set up using the nagios types. Mostly it works fine, but sometimes I find that the generated puppet-hosts.cfg file keeps growing - the hosts are just added and re-added ad nauseam. Deleting the file and running puppetd -t
regenerates it fine.
Our nagios host bit in the puppet nagios module is:
# set up alias
$real_nagios_alias = $nagios_alias ? { '' => $hostname, default => $nagios_alias }
$real_nagios_contact_groups = $nagios_contact_groups ?
{ '' => 'admins', default => $nagios_contact_groups }
$real_nagios_parents = $nagios_parents ? { '' => '', default => $nagios_parents }
$default_nagios_hostgroups = 'all-servers'
$real_nagios_hostgroups = $nagios_hostgroups ?
{ '' => $default_nagios_hostgroups, default => $nagios_hostgroups }
@@nagios_host { $hostname:
ensure => present,
address => $fqdn,
alias => $real_nagios_alias,
contact_groups => $real_nagios_contact_groups,
hostgroups => $real_nagios_hostgroups,
parents => $real_nagios_parents,
use => 'generic-host',
target => $nagios_puppet_host_file,
}
($nagios_puppet_host_file
is defined in the main manifests/site.pp file). In the nagios server class we have the line:
Nagios_host <<||>> { notify => Service['nagios'] }
When running puppetd -t
on the nagios server, I often get an error along the lines of:
err: Could not prefetch nagios_host provider 'naginator': Could not parse configuration for nagios_host: line 15: syntax error at '
' in /usr/local/nagios/etc/puppet-hosts.cfg
The line number varies, but when I look in the file, the line number will line up with something like:
define host {
address somehost.example.org
contact_groups admins
The line number will be the line with "address" on it. Apart from that I've not spotted a pattern to which host it complains about.
So is there any reason why the hosts keep getting regenerated?
Puppet version is 0.25.4 generally, including on the puppet server, though it is 2.6.2 on the nagios server, which I guess may be the problem.
I think you're running into something related to Puppet Bug #4076. One workaround is to use David Schmitt's nagios module instead.