notify behavior on a service Puppet 4.2.2

75 views
Skip to first unread message

Mike Sharpton

unread,
Jun 20, 2016, 11:55:06 AM6/20/16
to Puppet Users
Hey all,

I have a simple chunk of code, in which if a file is changed, I notify a service to restart.  This all works fine.  I had thought that notify is simply just a notify that forces something to run.  I also thought that the code that you are notifying will always run, regardless of the dependent object being ran (even if the file doesn't change, the service code is still executed).  In my testing, this does not appear to be the case.

Code snip:

file { 'something':
    source => "puppet:///modules/${module_name}/something",
    path   => "/somepath/something",
    mode   => "0755",
    owner  => "root",
    group  => "root",
    ensure => "file",
    notify => Service['someservice'],
  }

  service { 'someservice':
    enable   => 'true',
    ensure   => 'running',
    provider => 'redhat',
  }   
What I am finding is that I can stop someservice above and do a puppet run. The service is not started by Puppet.  The service block of code is not executed at all unless file "something" changes.  Is this the expected behavior?  I read the puppet doc and it doesn't get real clear on this.  I would think the service code would always execute, but it appears the notify relationship is stopping that from happening.
Mike

Mike Sharpton

unread,
Jun 20, 2016, 12:04:43 PM6/20/16
to Puppet Users
In looking more, it appears if you complete the relationsip with a require going the other way, it will run the service code each time.  Trying more things.

Mike Sharpton

unread,
Jun 20, 2016, 2:07:14 PM6/20/16
to Puppet Users
Found the cause, it isn't notify or relationships.  It's the fact that the init script is no good.  It always exits zero even when it isn't running.  This does not help.  I had to use the hasstatus parameter.  All is well.


On Monday, June 20, 2016 at 10:55:06 AM UTC-5, Mike Sharpton wrote:
Reply all
Reply to author
Forward
0 new messages