Ask Your Question

How to do a puppetserver restart through manifest [closed]

asked 2016-12-13 16:59:35 -0500

I have a scenario where i am managing hiera.yaml and eyaml backend through a module and at the end of the module run, i should restart the puppetserver for it to take the latest changes into effect.

How do i do it in the manifest? Please provide examples, thanks!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Redsmile
close date 2017-01-31 15:56:36.720078


Any chance you could not implement that with puppet? Because puppet could fail. Then it won't be restarted. Maybe a separate service, cronjob, or whatever (but not puppet) should watch for triggering changes.

Kai Burghardt gravatar imageKai Burghardt ( 2016-12-14 12:09:39 -0500 )edit

I got it working by having puppet server service being notified of changes to hiera.yaml. I will think more about cronjob and other options too. Thank you!

Redsmile gravatar imageRedsmile ( 2016-12-14 15:22:44 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-12-14 07:55:31 -0500

DarylW gravatar image

To restart the puppetserver service, you would have to either notify the service resource for the puppet from your other even, or have your puppetserver service resource subscribe to the package/exec event. To be able to notify the service, you have to already be managing it somewhere in your catalog.

One example is from the puppet/hiera module from voxpupuli.. In this case, they are using the 'spaceship' or collection operator to add the subscription to the service. You also could put the notification directly on your package resource for something more 'direct', but both have the same output.

#Lines 82-84
  Service <| title == $::hiera::master_service |> {
    subscribe +> $master_subscribe,

It looks like in the case of the puppetserver, they are actually using an exec to 'install' the gem using the puppetserver gem install command...

#Lines 67-72
      exec { "install puppetserver gem ${gem_name}":
        command => "puppetserver gem install ${source_flag} ${gem_name} ${gem_flag}",
        unless  => "find ${puppetserver_gem_dir} -mindepth 1 -maxdepth 1 -type d -exec basename {} \\; | egrep -q '^${gem_name}-([0-9].?)+$'",
        #unless  => "puppetserver gem list -i '^${name}$'", # Suuuuper slow
      $master_subscribe = Exec["install puppetserver gem ${gem_name}"]
  } else {
    package { $gem_name:
      ensure   => $gem_ensure,
      provider => $provider,
      source   => $gem_source,
    $master_subscribe = Package[$gem_name]
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-12-13 16:59:35 -0500

Seen: 31 times

Last updated: Dec 14 '16