我刚刚设置puppet来生成nagiosconfiguration文件,这是伟大的:)我有服务被放在一个名为$nagios_puppet_service_file的文件,这里是nagios服务类的一部分:
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, }
虽然我的一个服务定义如下所示:
$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, }
所以服务文件是正确生成的,但是nagios服务没有重启,尽pipe在上面的服务部分有subscribe子句。 (好吧,有时它会在文件权限被更新时重新启动,但是这并不总是发生在木偶上,有时偶尔会发生在木偶的运行中,所以只有一些更改会被加载,尽pipe它们都在服务文件。)
任何想法为什么订阅子句不按预期工作? 我可以订阅所有的nagios_service实例吗? 在nagios_service位通知将工作更好吗?
该文件的内容不受file语句的控制,该file语句是具有notify的file语句。 你应该notify nagios_service 。
虽然没有办法使service订阅所有的nagios_service ,但你可以这样做:
Nagios_service <<||>> { notify => Service['nagios'] }
但是我没有看到这个notify属性没有理由在导出的nagios_service实例上定义。