class level notify

33 views
Skip to first unread message

Johan Martinez

unread,
Jan 12, 2016, 4:46:42 PM1/12/16
to Puppet Users

I want to notify a service whenever certain config files change. Rather than putting notify function in every resource, can class level notify with chaining arrow/tilda work here?


I have defined multiple file resources inside config class. Will something like below notify service class if any of the resources in config class are applied/changed?

Class['site::config'] ~> Class['site::service']

--
jM

jcbollinger

unread,
Jan 13, 2016, 9:10:17 AM1/13/16
to Puppet Users
TL;DR: yes.

In more detail, the Language Reference describes how containment interacts with event broadcast and reception (the mechanism underlying resource notification and refreshing).  In particular,

If Puppet changes (or refreshes) any resource in a class or defined resource, that class or defined resource will send a refresh event to any subscribed resources.

and

If a class or defined resource gets a refresh event, every resource it contains will also get a refresh event.

Those both apply to the example you presented.

One thing to watch out for, however, is that the event broadcasting produced by a declaration such as you presented may be more than you actually want.  That is, there must not be any resources in Class['site::config'] from which you do not want to receive events, nor any in Class['site::service'] to which the events should not be directed.


John

Reply all
Reply to author
Forward
0 new messages