How to force a puppet service to restart - Not restarting automatically when config is initially updated.

10,046 views
Skip to first unread message

Robert Shady

unread,
Feb 22, 2014, 10:35:09 PM2/22/14
to puppet...@googlegroups.com
(I posted this yesterday, but for some reason it never showed up)...

First off, master & agent are Debian Linux boxes running Wheezy (Debian 7.4).
Puppet Master and Agent are V3.4.3

So here's the deal.. I'm trying to install PowerDNS recursor on my agent
with a custom configure file (/etc/powerdns/recursor.conf).  All of that
works, but what is happening is:

1. The package is installed...
2. The service is started...
3. The configuration is updated..
4. The service is NOT restarted..

So pdns-recursor is running with the old configuration.

Here is my setup on my master:

package { 'pdns-recursor':
  ensure => installed,
}


file { '/etc/powerdns/recursor.conf':
  ensure  => file,
  owner   => 'pdns',
  group   => 'pdns',
  mode    => '0644',
  require => Package['pdns-recursor'],
  notify  => Service['pdns-recursor'],
  source  => 'puppet:///configs/powerdns/recursor.conf',
}


service { 'pdns-recursor':
  ensure     => 'running',
  enable     => 'true',
}


Any ideas on how to fix this?  I have a similar problem with another service (fail2ban)
that installs a custom configuration in /etc/fail2ban/jail.local (which doesn't exist
in the default installation, but Debian does a smart include).

1. Fail2Ban is installed
2. Fail2Ban is started.
3. Custom configuration is installed
4. Fail2Ban does NOT restart.

P.S. On a side note, I have a bootstrap process that takes a new server, installs
Salt & Puppet, puppet then connects to the master, I sign the key - but then
nothing happens.  I have to service puppet restart on the agent in order for it
to pick up any of the changes.  Once I do that, it automatically checks every
1800 seconds as normal.  Is there some way around this?

-- Rob

Dan White

unread,
Feb 22, 2014, 10:50:14 PM2/22/14
to puppet...@googlegroups.com
The "notify" parameter on the file resource should make it happen. 
Have you tried a run in debug mode ?
It can maybe show you what might be missing. 
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/8075eb6a-8b3e-4be8-baae-8629a8dffc6b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Russell Cecala

unread,
Feb 22, 2014, 11:07:01 PM2/22/14
to puppet...@googlegroups.com
Should the notify on the file resource "notify" and Exec that does "service pdns-recursor restart"

...
notify => Exec['restart']
...

Exec { 'restart':
    command => '/sbin/service pdns-recursor restart'
}

something like that maybe?


Robert Shady

unread,
Mar 1, 2014, 8:55:23 AM3/1/14
to puppet...@googlegroups.com
Sorry for such a delay in replies, I had figured this out and forgot about this thread. ;)

Yes, I did run it in debug mode and found out the problem was that pdns-recursor
does not have a 'status' available, so puppet didn't know what to do.

I implemented the status function in /etc/init.d/pdns-recursor and now everything
is working properly.  Thank you so much for your help!

-- Rob

Jeff Bachtel

unread,
Mar 1, 2014, 10:40:57 AM3/1/14
to puppet...@googlegroups.com
While implementing restart is good, if for some reason you were unable to do that you need only set hasrestart => false for the service resource, per http://docs.puppetlabs.com/references/latest/type.html#service . That will cause Puppet to issue a service stop then service start, instead of attempting service restart.

Jeff

jcbollinger

unread,
Mar 3, 2014, 12:07:58 PM3/3/14
to puppet...@googlegroups.com


On Saturday, March 1, 2014 9:40:57 AM UTC-6, Jeff Bachtel wrote:
While implementing restart is good, if for some reason you were unable to do that you need only set hasrestart => false for the service resource, per http://docs.puppetlabs.com/references/latest/type.html#service . That will cause Puppet to issue a service stop then service start, instead of attempting service restart.

Jeff

On 03/01/2014 08:55 AM, Robert Shady wrote:
Sorry for such a delay in replies, I had figured this out and forgot about this thread. ;)

Yes, I did run it in debug mode and found out the problem was that pdns-recursor
does not have a 'status' available, so puppet didn't know what to do.


Quite true.  And you can also specify a different restart procedure via the Service's 'restart' property.

None of that is directly relevant to the Service's 'status' command, however, which is where the OP reported the problem residing.  Services really, really should have working 'status' commands.  Moreover, although Puppet has a default method for trying to determine the status of a Service declared with hasstatus => false, it is just a best guess, unsuitable for some services.

The good news is that you can also specify a custom 'status' command for your service in Puppet.  If ever you need to declare hasstatus => false, I highly recommend explicitly declaring a 'status' command, too.


John

Reply all
Reply to author
Forward
0 new messages