Mat*_*ons 13 ubuntu service puppet
我正在使用 puppet(理论上)让 npcd 在安装时启动,但是在 Ubuntu 上,该服务随 RUN="no" 的 /etc/default/npcd 中的默认设置一起安装:
$ cat /etc/default/npcd
# Default settings for the NPCD init script.
# Should NPCD be started? ("yes" to enable)
RUN="no"
# Additional options that are passed to the daemon.
DAEMON_OPTS="-d -f /etc/pnp4nagios/npcd.cfg"
Run Code Online (Sandbox Code Playgroud)
我认为这个 puppet 配置块会处理以下事情:
service { "npcd":
enable => true,
ensure => "running",
require => Package["pnp4nagios"],
}
Run Code Online (Sandbox Code Playgroud)
但可惜,它没有,而且没有实际重写 /etc/default 中的文件,我不知道该怎么做。有没有一种直接的方法来启用我没有看到的服务?
作为记录,我使用的是 Ubuntu 12.04.2 和 puppet 版本 3.1.0。
Luk*_*uke 12
更新该文件然后重新启动服务是唯一的方法。您可以推送一个新文件,然后让服务需要该文件;这样,当内容更新时,服务将正确启动。
如果您不想完全替换文件,您可以使用 Puppet augeas 工具来修改默认文件中的单行。
Debian 及其衍生产品中有一些服务在安装软件包后不会自动启动,除非在 /etc/default 中启用。有点烦。
编辑:仅供参考,init 脚本实际上是从该文件中读取值(通常只是获取它)。
不管怎样,我检查了我的 12.04 机器上的一些标准守护进程。您必须管理文件,目前无法绕过它。
snmpd
# snmpd control (yes means start daemon).
SNMPDRUN=yes
Run Code Online (Sandbox Code Playgroud)
收藏
# 0: start collectd on boot, 1: do not start collectd on boot
# default: 0
DISABLE=0
Run Code Online (Sandbox Code Playgroud)
木偶
# Start puppet on boot?
START=yes
Run Code Online (Sandbox Code Playgroud)
妈妈
# START_DAEMON:
# should mdadm start the MD monitoring daemon during boot?
START_DAEMON=true
Run Code Online (Sandbox Code Playgroud)
代理
# Set ENABLED to 1 if you want the init script to start haproxy.
ENABLED=1
Run Code Online (Sandbox Code Playgroud)
我认为一种可行的方法是使用带有木偶的 augeas 工具,例如
augeas { "npcd_default":
changes => [
"set /files/etc/default/npcd/Run yes",
],
}
Run Code Online (Sandbox Code Playgroud)
详情请参阅手册