I've just set up puppet to generate nagios config files, which is great :) I have the services being put into a file named as $nagios_puppet_service_file
and here is part of the nagios service class:
file { $nagios_puppet_service_file:
ensure => file,
owner => nagios, group => admins, mode => '0664',
notify => Service['nagios'],
}
Nagios_host <<||>>
Nagios_hostextinfo <<||>>
Nagios_service <<||>>
service { 'nagios':
ensure => running,
enable => true,
subscribe => [ File[$nagios_puppet_host_file], File[$nagios_puppet_hostextinfo_file],
File[$nagios_puppet_service_file], ],
hasrestart => true,
hasstatus => true,
}
While one of my service definitions looks like:
$real_nagios_http_port = $nagios_http_port ? { '' => '80', default => $nagios_http_port }
$real_nagios_http_url = $nagios_http_url ? { '' => '/', default => $nagios_http_url }
$real_nagios_http_addr = $nagios_http_addr ? { '' => $fqdn, default => $nagios_http_addr }
@@nagios_service { "check_http_port_${hostname}":
use => 'generic-service',
check_command => "check_http_port!$real_nagios_http_addr!$real_nagios_http_port!$real_nagios_http_url",
service_description => 'HTTP service',
host_name => $hostname,
target => $nagios_puppet_service_file,
}
So the service file is generated correctly, but the nagios service is not restarted, despite the subscribe
clause in the service part above. (Well, sometimes it is restarted when the permissions on the file are updated, but that doesn't always happen on a puppet run, and sometimes happens part way through a puppet run, so only some changes get loaded, despite them all being in the services file.)
Any ideas why the subscribe clause isn't working as expected? Can I subscribe to all nagios_service instances some how? Would a notify in the nagios_service bit work any better?
The contents of the file are not being controlled by the
file
statement, which is the one with thenotify
. You should putnotify
onnagios_service
.And while there isn't a way to make
service
subscribe to allnagios_service
, you can do it the other way around like this:But I see no reason for this
notify
attribute not to be defined on the exported instances ofnagios_service
to begin with.