5

I have this puppet module (monit) in which I declare monit service to be enabled (a.k.a to be started when the machine booted)

class monit {
    $configdir = "/etc/monit.d"

    package {
        "monit": ensure => installed;
    }

    service { "monit":
        ensure => running,
        enable => true,
        require => Package["monit"],
        provider => init;
    }

    file {
        '/etc/monit.d':
            ensure => directory;
        '/etc/monit.conf':
            content => template('monit/monitrc.erb'),
            mode => 0600,
            group => root,
            require => File['/etc/monit.d'],
            before => Service[monit],
            notify => Service[monit],
    }
}

I then included with include monit inside default node. However, when I apply this configuration, puppet is not setting monit as a start up service (use chkconfig --list monit just display 'off' and 'off')

However, if I run puppet apply -e 'service { "monit": enable => true, } ' then monit is added to start up properly.

Am I doing any thing wrong here? (Puppet 2.7.6)

The full configuration can be view at https://github.com/phuongnd08/Giasu-puppet

Phương Nguyễn
  • 8,747
  • 15
  • 62
  • 96

1 Answers1

8

The issue is probably the provider => init line, which is overriding the default provider for handling services. The init provider is a very simple provider that doesn't support the "enableable" feature, so it can't set a service to start on boot.

See http://docs.puppetlabs.com/references/2.7.6/type.html#service for its capabilities.

In your puppet apply example, you don't specify the provider so it picks the most appropriate for your system - in your case the "redhat" provider that uses chkconfig.

To fix this, remove the provider line from your service {} definition and it will again default to the most appropriate. You only need to specify a provider if it picks incorrectly and then it's best to specify it as a global default.

Dominic Cleal
  • 3,205
  • 19
  • 22
  • You may also want to consider replacing the "/etc/monit.conf" with "$configdir" in the first file block. Otherwise if you change the $configdir value later on, puppet may update the /etc/monit.conf file to refer to the new directory, but puppet won't make sure the new directory is present. – pwan May 15 '12 at 12:36