I'm using puppet to (theoretically) get npcd to start upon installation, however on Ubuntu, that service comes installed with the default setting in /etc/default/npcd of RUN="no":
$ 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"
I would think that this block of puppet config would take care of things:
service { "npcd":
enable => true,
ensure => "running",
require => Package["pnp4nagios"],
}
But alas, it doesn't, and short of actually rewriting the file in /etc/default, I'm not sure what to do. Is there a straightforward way to enable the service that I'm not seeing?
For the record, I'm using Ubuntu 12.04.2 and puppet version 3.1.0.
Updating that file and then restarting the service is the only way. You can push a new file and then make the service Require that; that way when the contents are updated the service will properly start.
If you don't want to replace the file entirely you can use the Puppet augeas tool to just modify the single line in the defaults file.
There are a few services in Debian and its derivatives that don't autostart after the package is installed unless it's enabled in /etc/default. Kind of annoying.
Edit: FYI the init script is actually reading the values from that file (just sourcing it usually).
For the hell of it I checked a few of the standard daemons on my 12.04 machines. You have to manage the file, no way around it at this point in time.
snmpd
collectd
puppet
mdadm
haproxy
I think one of feasible ways to do it is using augeas tool with puppet, e.g.
refer to the manual for details
I use sed to modify the file. Augeas seems like overkill.
Idea taken from here:
http://www.codelord.net/2010/12/19/using-puppet-to-automatically-configure-new-ec2-instances/
So, in your case
Doing this with the
augeas
type in Puppet is one way (as suggested by @DukeLion).Another way is to use the
augeasproviders
module, with theshellvar
provider:This is better because Augeas will be used cleanly by the Ruby provider. It will also manage quoting and comment automatically.