如何使用 Puppet 管理 puppet.conf?

Cor*_*ren 11 puppet

我使用 puppet 来管理 linux 服务器和各种服务。它运行良好,除了puppet服务本身。

我的木偶课是这样的:

class puppet {
  file { "/etc/puppet/puppet.conf":
    owner  => 0, group  => 0, mode => 0644,
    content => template("${module_name}/puppet.conf.erb"),
  }

  service { "puppet":
    name       => "puppet",
    ensure     => running,
    enable     => true, hasstatus  => true, hasrestart => true,
    require    => File["/etc/puppet/puppet/conf"]
    subscribe  => File["/etc/puppet/puppet/conf"]
  }
}
Run Code Online (Sandbox Code Playgroud)

}

当对 /etc/puppet/puppet.conf 应用更改时,puppet 会注意到它需要重新启动 puppet 服务,因此会自行崩溃:

Mar 30 17:08:23 XXXX puppet-agent[20172]: (/Stage[main]/Puppet/File[/etc/puppet/puppet.conf]/content) content changed '{md5}eeaf5dfc7d88c8d9c85e6a8cc714d702' to '{md5}ef6ff0e423f4125e24b689980df9f71d'
Mar 30 17:08:23 XXXX puppet-agent[20172]: Caught TERM; calling stop
Run Code Online (Sandbox Code Playgroud)

你知道我如何用 puppet 正确更新 puppet.conf 吗?

小智 10

puppet 守护进程将自动通知 puppet.conf 文件的更改,而无需重新启动。只需删除subscribe => File["/etc/puppet/puppet.conf"]from service { "puppet" ... },一切仍然有效。

傀儡也不能真正ensure => running为自己。但是,使用类似Mutal Restart with puppet 之类的东西确保 cron 正在运行,使用 cronjob 确保 puppet 正在运行是可行的。