notify vs. require of services

1,160 views
Skip to first unread message

Axel Bock

unread,
Sep 5, 2012, 4:47:03 AM9/5/12
to puppet...@googlegroups.com
Hi readers,

I had this idea. I am deploying a configuration file of a service with puppet, and I want to restart the service if the file changes.

so I had this idea that the file definition contains a require=> and a notify=> for the service.
that does not work, because Puppet does assume cyclic dependencies then.

And I have no clue whatsoever why. both statements go from file to service (or from service to file, however you like to put it), but I really don't see a cyclic dependency here.


can anyone help me out?
thanks in advance,
axel.

R.I.Pienaar

unread,
Sep 5, 2012, 4:49:14 AM9/5/12
to puppet...@googlegroups.com
file{"x": require => Service["y"], notify => Service["y"]}

The require says 'do the service before the file' while the notify says
'once the file changed, restart the service'.

You cant manage the service both before and after a file so there's a
conflict.

Axel Bock

unread,
Sep 5, 2012, 5:18:31 AM9/5/12
to puppet...@googlegroups.com
hm, I still don't see the logic.

I think this is a common scenario (please tell me I'm wrong) that you ensure presence of a service generally, and then deploy a config file, and on changes you want - of course - the service to be restarted. or ... not?!

is there a puppet pattern on how to do this maybe?


Thanks,
Axel.

R.I.Pienaar

unread,
Sep 5, 2012, 5:25:44 AM9/5/12
to puppet...@googlegroups.com


----- Original Message -----
> From: "Axel Bock" <axel...@arbeitsagentur.de>
> To: puppet...@googlegroups.com
> Sent: Wednesday, September 5, 2012 10:18:31 AM
> Subject: [Puppet Users] Re: notify vs. require of services
>
> hm, I still don't see the logic.
>
> I think this is a common scenario (please tell me I'm wrong) that you
> ensure presence of a service generally, and then deploy a config
> file, and on changes you want - of course - the service to be
> restarted. or ... not?!

why would you start a service before the config file is deployed?
surely you want to configure the service before starting it?

Puppet only manage any resource once during the process of applying
the catalog, so the common pattern is:

package{"something": ...}
file{"/etc/something/config": require => Package["something"], notify => Service["something"]}
service{"something":...}

this way it installs, then configures and then starts the service.

In future any change to the config file will restart the service.

Axel Bock

unread,
Sep 5, 2012, 5:33:57 AM9/5/12
to puppet...@googlegroups.com
Am Mittwoch, 5. September 2012 11:25:51 UTC+2 schrieb R.I. Pienaar:
why would you start a service before the config file is deployed?
surely you want to configure the service before starting it?

sure :) . that's what I meant, basically.  
 
so the common pattern is:

package{"something": ...}
file{"/etc/something/config": require => Package["something"], notify => Service["something"]}
service{"something":...}

duh! thanks for that. obvious of course.

thanks again!
Axel.
 

jcbollinger

unread,
Sep 5, 2012, 10:13:53 AM9/5/12
to puppet...@googlegroups.com


I see that RIP gave you something you can use, but it's not clear whether you figured out your underlying misunderstanding about relationships.  In particular, you seem to have been missing the point that relationships are directional, or perhaps you mistook the direction of the 'notify' relationship.  The 'notify' relationships have directionality as 'before' relationships, opposite to that of 'require', and in fact 'notify' is best viewed as a specialization of 'before'.  That is why you had a cycle.

Moreover, no resource ever needs to declare more than one type of relationship with the same other resource.  'notify' is a specialization of 'before', so you don't need both or those, 'subscribe' is a specialization of 'require', so you don't need both of those, and all the other mixed pairs represent cycles.


John

Eric Sorenson

unread,
Sep 5, 2012, 7:40:59 PM9/5/12
to puppet...@googlegroups.com


On Wednesday, September 5, 2012 7:13:53 AM UTC-7, jcbollinger wrote:

  'notify' is a specialization of 'before', so you don't need both or those, 'subscribe' is a specialization of 'require', so you don't need both of those, and all the other mixed pairs represent cycles.


John -- this is a wonderfully succinct way of describing the relationships between these parameters. I'd never really thought about them (nor seen it put) quite that way. Thanks!

-=Eric 

Axel Bock

unread,
Sep 10, 2012, 8:39:27 AM9/10/12
to puppet...@googlegroups.com


Am Mittwoch, 5. September 2012 16:13:53 UTC+2 schrieb jcbollinger:
perhaps you mistook the direction of the 'notify' relationship. 

this is it :) . thank you very much for this precise explanation :)
Reply all
Reply to author
Forward
0 new messages