Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Puppet does not add my service to start up

Tags:

puppet

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

like image 306
Phương Nguyễn Avatar asked Nov 06 '11 02:11

Phương Nguyễn


People also ask

How do you restart a puppet service?

The actual command used to restart the service depends on the platform and can be configured: If you set hasrestart to true, Puppet will use the init script's restart command. You can provide an explicit command for restarting with the restart attribute.

What is puppet provider?

Puppet has different types like a service type, package type, provider type, etc. Wherein each type has providers. The provider handles the configuration on different platforms or tools. For example, the package type has aptitude, yum, rpm, and DGM providers.

Which of the following file does puppet agent downloads from Puppet Master?

Puppet. conf file is Puppet's main configuration file. Puppet uses the same configuration file to configure all the required Puppet command and services. All Puppet related settings such as the definition of Puppet master, Puppet agent, Puppet apply and certificates are defined in this file.


1 Answers

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.

like image 99
Dominic Cleal Avatar answered Oct 07 '22 01:10

Dominic Cleal