我有一个通知傀儡代理的文件。
在network模块中,代理设置包含在.gemrc文件中,如下所示:
file { "/root/.gemrc": content => "http_proxy: $http_proxy\n", notify => Service['puppet'], }
问题是傀儡停下来,不重新启动。
Aug 31 12:05:13 snch7log01 puppet-agent[1117]: (/Stage[main]/Network/File[/root/.gemrc]/content) content changed '{md5}2b00042f7481c7b056c4b410d28f33cf' to '{md5}60b725f10c9c85c70d97880dfe8191b3' Aug 31 12:05:13 snch7log01 puppet-agent[1117]: Caught TERM; calling stop
我假设代码做了像/etc/init.d/puppet stop && /etc/init.d/puppet start类的东西。由于puppet没有运行,所以它不能启动…这是有道理的。
当这个文件改变时如何让puppet自动重启? 请注意,该文件可能不存在。
您可能需要添加到“puppet”的服务资源声明中:
hasrestart => true,
除了确保“hasrestart”在清单中,您还应该确保
"ensure => running"
在清单中。 这是我的副本:
class puppet::service { service { puppet: ensure => running, enable => true, hasrestart => true, subscribe => File["/etc/puppet/puppet.conf"], } }
我有一个类似的问题。 我需要部署修补程序到augeas,并使用puppet来部署它们,但是直到puppetd重新启动才会生效。 所以我需要一个快速简单的方法来告诉puppetd重启一次。 我用一个shell脚本和一个exec来解决这个问题。
这是脚本:
#!/bin/bash if [ X"$1" != Xbackground ]; then OUTDIR=/var/log/puppet mkdir -p $OUTDIR nohup $0 background > $OUTDIR/puppet_restart.out 2>&1 < /dev/null & exit 0 fi # If you get here, this is a background copy of this script that has # been decoupled from puppet by the nohup above. Give puppet a chance # to finish what it is doing, then restart it. sleep 60 /sbin/service puppet restart
运行脚本的清单使用它创build的日志文件。 (这是第一次正常工作 – 如果您进行后续更新,请创build一个将删除日志文件的清单,以便再次运行一次):
file { "/usr/local/bin/puppet_restart": owner => root, group => root, mode => 750, source => "puppet:///modules/puppet_fix_module/puppet_restart" } exec { "restart_puppet": command => "/usr/local/bin/puppet_restart", path => ["/usr/bin", "/usr/sbin", "/bin"], creates => "/var/log/puppet/puppet_restart.out", require => [ File['/usr/local/bin/puppet_restart'], File ["/some/other/file/that/requires/restart"], ] }