当服务同时描述ensure => running
并订阅配置文件更改时,如果两个条件都满足(即它未运行且配置文件已更改),它将(重新)启动两次。有没有办法让它只启动一次?
为了澄清起见,我有以下类型:
service { "puppet":
ensure => running,
enable => true,
hasrestart => true,
subscribe => File["/etc/puppet/puppet.conf"],
} # service
什么时候两个都 /etc/puppet/puppet.conf
已更改并且服务 puppet 没有运行我在 puppet 输出中看到以下内容(指定了 --debug):
....
debug: /Stage[main]/Puppet/Service[puppet]/subscribe: subscribes to File[/etc/puppet/puppet.conf]
notice: /Stage[main]/Puppet/File[/etc/puppet/puppet.conf]/content: content changed '{md5}c39350dd1e135cf9fffd14ff167d6655' to '{md5}845a4aac5e83ab3f8cd9efd80ce17772'
....
info: /etc/puppet/puppet.conf: Scheduling refresh of Service[puppet]
debug: /etc/puppet/puppet.conf: The container Class[Puppet] will propagate my refresh event
info: /etc/puppet/puppet.conf: Scheduling refresh of Service[puppet]
debug: Service[puppet](provider=debian): Executing '/etc/init.d/puppet status'
debug: Service[puppet](provider=debian): Executing '/etc/init.d/puppet start'
notice: /Stage[main]/Puppet/Service[puppet]/ensure: ensure changed 'stopped' to 'running'
debug: /Stage[main]/Puppet/Service[puppet]: The container Class[Puppet] will propagate my refresh event
debug: Service[puppet](provider=debian): Executing '/etc/init.d/puppet status'
debug: Service[puppet](provider=debian): Executing '/etc/init.d/puppet restart'
err: /Stage[main]/Puppet/Service[puppet]: Failed to call refresh: Could not restart Service[puppet]: Execution of '/etc/init.d/puppet restart' returned 1: at /etc/puppet/modules/puppet/manifests/init.pp:32
这显然会失败,原因如下:
root:~# /etc/init.d/puppet restart ; /etc/init.d/puppet restart
* Restarting puppet agent [ OK ]
* Restarting puppet agent [fail]
有办法解决这个问题吗?
答案1
Puppet IRC 频道回答了我的问题。
这是 Puppet 的一个 bug,描述如下: http://projects.puppetlabs.com/issues/show/9656
答案2
我目前还没有安装 Puppet,但有几件事:
- 你正在运行哪个版本的 Puppet?
- 当我忘记将“hasstatus => true”添加到我的服务时,总是会发生一些奇怪的事情。它可能无法解决您的问题,但不会造成任何损害。