2

Especially when setting up a completely new server from the scratch, puppet tends to start dependant services as soon as all their dependencies are satisfied. This sometimes leads to situation that services are started unnecessarily too early while the setup of other packages (not maybe dependant of a service) is still running.

Is there any one-liner definition or recipe that would automatically make all services to start/refresh in the end of the whole catalogue run? I tried to figure out if run stages could be utilized but that would, in my understanding, require that all service definitions are explicitly defined to "last" stage.


Update 1: Some background to my question. Puppet, during the initial setup of a node, works rather intensively and thus reserves resources of a fairly small virtual machine (in my case, Vagrant on dev machine). When the setup phase came to a point that some of the services, in my case the background workers, were ready, Puppet starts them and the workers start to receive jobs from a queue. This workload slows down the still-going-on Puppet node setup process as well as the Puppet slows down the workers, until the whole setup is done and the box is in a stable state.

This is why I started to think that it would be good to let Puppet to work the initial setup to its end before all services on the node are started and why I was wondering whether there is any simple way to do this with Puppet.

Ville Mattila
  • 459
  • 7
  • 13

3 Answers3

4

I would advise against a global restart. Rather, use puppet dependencies.

Something like:

service { 'first':
      ensure    => running,
      enable    => true,
    }

service { 'second':
      ensure    => running,
      enable    => true,
      subscribe => Service['first']
}
dmourati
  • 25,540
  • 2
  • 42
  • 72
  • Yes, dependencies would be the best solution whenever the services really are dependant from each other. What I am looking for here is to avoid services to start in the middle of the provisioning process (some other, non-dependant packages, services, files etc) to be installed on the same server. – Ville Mattila Dec 04 '13 at 06:45
1

You don't.

That's entirely not what puppet is supposed to do, and though you can probably come up with a way of doing it, it's not a good idea at all. If all you want to achieve is that services shouldn't slow down puppet (which I also find rather backward, I'd prefer it the other way around), why not teach your services to take it easy if puppet is running while they get started?

Dennis Kaarsemaker
  • 19,277
  • 2
  • 44
  • 70
0

One way to accomplish this is to

  1. Have the subscribe as mentioned above.
  2. Use the stage metaparameter.

You can assign this as a default value to the Service resource type via

Service { stage => last }

If you define this in your nodes.pp it will apply to all nodes, or you can define it per node.

рüффп
  • 620
  • 1
  • 11
  • 25