如何使用Puppet管理puppet.conf?


11

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

我的木偶课是这样的:

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"]
  }
}

}

当对/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

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

Answers:


10

puppet守护程序将自动注意到对puppet.conf文件的更改,而无需重新启动。只需subscribe => File["/etc/puppet/puppet.conf"]从中删除service { "puppet" ... },一切仍然可以正常使用。

木偶也不是真正ensure => running适合自己。但是,使用类似木偶的Mutal Restart来确保cron正在运行,并且使用cronjob来确保puppet正在运行将起作用。


我会检查它是否在星期一工作,但对我来说似乎很好。感谢您提供有关相互重启的指示。
Coren

1

一种解决方案是不将puppet作为守护程序运行,而是从cron调用它。这是很多人喜欢的东西,因为对于他们而言,守护程序会占用大量内存。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.