Fixing services that have been disabled in /etc/default/ with puppet?

Solution 1:

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).

Solution 2:

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

# snmpd control (yes means start daemon).
SNMPDRUN=yes

collectd

# 0: start collectd on boot, 1: do not start collectd on boot
# default: 0
DISABLE=0

puppet

# Start puppet on boot?
START=yes

mdadm

# START_DAEMON:
#   should mdadm start the MD monitoring daemon during boot?
START_DAEMON=true

haproxy

# Set ENABLED to 1 if you want the init script to start haproxy.
ENABLED=1

Solution 3:

I think one of feasible ways to do it is using augeas tool with puppet, e.g.

augeas { "npcd_default":
  changes => [
    "set /files/etc/default/npcd/Run yes",
  ],
}

refer to the manual for details