2

In puppet, if you enable a service like this:

service { 'myservice':
    ensure => running,
    enable => true,
    subscribe => File['/etc/init.d/myservice'];
}

file { '/etc/init.d/myservice':
    source => "puppet:///modules/myservice/myservice",
    ensure => file,
    owner => root,
    group => root,
    mode => '0755',
 }

Then puppet creates /etc/rc3.d/S??myservice and in my case, it always creates S65myservice. Where does the 65 come from? If puppet is choosing 65 consistently, it must be determined somewhere, but I don't know how it's making that decision. How do I make this service start later in the boot process? (for example S99myservice)

Edward Ned Harvey
  • 6,525
  • 5
  • 36
  • 45
  • Some things here: 1. unquoted `mode` octal attributes are either a warning or error depending on your version of Puppet 2. you meant to use `source` and not `content` in the `file` resource 3. you probably want `subscribe` and not `require` for your `file` resource 4. it is safer to do `ensure => file` than `ensure => present` here – Matthew Schuchard May 26 '16 at 23:04
  • 1
    i'm guessing you are using an EL distrobution of linux. puppet isn't creating the file in `/etc/rc3.d/` the OS is. rc3 is runlevel 3. Chances are the `enable => true` is probably ensuring that the service is started at boot and ensuring that its started at runlevel 3 (Multi-user mode with networking). So this isn't a matter of puppet, it sees to be a matter of OS. – ptierno May 27 '16 at 05:16
  • @MattSchuchard none of your remarks remotely have anything to do with the question that was asked. – ptierno May 27 '16 at 05:21
  • @ptierno True, but it would be irresponsible of me not to help fix the problems in the code he posted. – Matthew Schuchard May 27 '16 at 11:25
  • Thanks for the comments. I've updated the question to include the improvements, except: It's actually ok to use `source` or `content` depending on your desired behavior. – Edward Ned Harvey May 27 '16 at 18:58
  • @EdwardNedHarvey, yes, of course it's OK to use either `source` or `content` (but not both), depending on your desired behavior. In this case, however, it is implausible that you really intended to manage the *content* of your initscript to be the string "puppet:///modules/myservice/myservice". – John Bollinger May 27 '16 at 21:22

1 Answers1

3

The order can be changed by adding a chkconfig clause to the startup script, such as:

#!/bin/sh
#
# chkconfig: 35 59 80

The above service should start at run level 3 and 5 using startup order 59, and shutdown order 80.
http://lpetr.org/blog/archives/startup-order-of-services-on-rhel-or-centos

Edward Ned Harvey
  • 6,525
  • 5
  • 36
  • 45