service restart upon notify

1,623 views
Skip to first unread message

puppetguest

unread,
Apr 12, 2012, 4:07:40 PM4/12/12
to Puppet Users
I have choosen to split my module into several .pp files as i have
seen in an example and makes it cleaner i think.

\modules\mysoftware\
init.pp
install.pp
config.pp
service.pp

Is that recommended or too many disadvantages ?

So my install.pp went through fine, config.pp as well.
When i change a config-file and puppet runs again i want the automatic
service restart but doesnt work unfortunately.

Does someone know the proper syntax how to trigger from config.pp the
function in service.pp for such a case ?

Examples like these dont work :-(
notify => Class["mysoftware::service"]
notify => Class["mysoftware::service::mysoftwarerestart"]
...


I should mention that the service has to restart via a shell-script,
not via init services !
So may be the service.pp needs some corrections too ?

service.pp

class mysoftware::service (
$user = "myuser",
) {

exec {"mysoftwarerestart":
command => "/opt/mysoftware/bin/script.sh restart",
require => Class["mysoftware::config"],
}

}

Trevor Smith

unread,
Apr 12, 2012, 6:39:55 PM4/12/12
to puppet...@googlegroups.com


On Thursday, April 12, 2012 4:07:40 PM UTC-4, puppetguest wrote:
I have choosen to split my module into several .pp files as i have
seen in an example and makes it cleaner i think.

\modules\mysoftware\
init.pp
install.pp
config.pp
service.pp

Is that recommended or too many disadvantages ?

So my install.pp went through fine, config.pp as well.
When i change a config-file and puppet runs again i want the automatic
service restart but doesnt work unfortunately.

Does someone know the proper syntax how to trigger from config.pp  the
function in service.pp for such a case ?

Examples like these dont work :-(
   notify  => Class["mysoftware::service"]
   notify  => Class["mysoftware::service::mysoftwarerestart"]
   ...


How about:

    notify => Exec['mysoftwarerestart']
 
You could also look at 'refreshonly' under the type reference for exec:  http://docs.puppetlabs.com/references/2.7.0/type.html#exec

Sans

unread,
Apr 13, 2012, 4:54:19 AM4/13/12
to Puppet Users
"notify => Class["mysoftware::service"]" should work without any
problem. Did you remember to include it beforehand?

include mysoftware::service


"notify => Exec['mysoftwarerestart']" should work too. Cheers!!

Frank Schaefer

unread,
Apr 13, 2012, 1:20:24 PM4/13/12
to puppet...@googlegroups.com
Works like a charm now:
include mysoftware::service
and
notify  => Class["mysoftware::service"],
Thanks!

 
2012/4/13 Sans <r.sant...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.


jcbollinger

unread,
Apr 16, 2012, 9:26:33 AM4/16/12
to Puppet Users


On Apr 12, 3:07 pm, puppetguest <amorph...@gmail.com> wrote:
> I have choosen to split my module into several .pp files as i have
> seen in an example and makes it cleaner i think.
>
> \modules\mysoftware\
> init.pp
> install.pp
> config.pp
> service.pp
>
> Is that recommended or too many disadvantages ?


The recommended method is to put each class and each definition in its
own file. If there is a class with the same qualified name as the
module then it goes in the init.pp; all other classes and definitions
should go into files whose names correspond to the name of the class
or definition they contain.

How you assign resources to classes is an entirely separate question.
That may be more what you were asking about, but if you want opinions
on that question then you'll need to show us what you're doing.


John
Reply all
Reply to author
Forward
0 new messages