Re: [Puppet Users] how to force tomcat restart using puppet kick and service type ?

236 views
Skip to first unread message

Felix Frank

unread,
Nov 5, 2014, 4:02:41 PM11/5/14
to puppet...@googlegroups.com
Hi,

good question. The module's documentation does not readily offer a way to cleanly restart a service.

However, looking at the source, it quickly becomes clear that tomcat::service does in fact wrap a service resource.

https://github.com/puppetlabs/puppetlabs-tomcat/blob/master/manifests/service.pp#L126-134

The nature of this resource depends on the parameters, apparently. But most (if not all) service providers will initiate a restart of the service if the resource receives a signal. You can enforce this by adding, say, a notify resource to your manifest.

notify { 'restarting tomcat': notify => Tomcat::Service['default'] }

A little confusing I guess - the notify type is not designed to enforce events. It actually notifies you with the given message ('restarting tomcat'). But since this is a sync action, it will also send an event to the service, thanks to the notify parameter.

HTH,
Felix

On 10/15/2014 09:07 AM, Richard wrote:
     I'm using the puppetlab-tomcat module.when i want to start tomcat ,i will kick the agent to run this code.
tomcat::service{'default':
      service_ensure => true,
      catalina_base  =>'/opt/apache-tomcat/tomcat',
}
     if i want to stop,i will change the service_ensure to false.
     but if i want to restart tomcat in one .pp file, just run kick command only once, i have to define two service because service name can't be duplicate declared. so i change the code:
tomcat::service{'default':
      service_ensure => false,
      catalina_base  =>'/opt/apache-tomcat/tomcat',
}
->
tomcat::service{'restart':
      service_ensure => true,
      catalina_base  =>'/opt/apache-tomcat/tomcat',
}
    after i using this code, i find i can't stop tomcat using this code
tomcat::service{'default':
      service_ensure => false,
      catalina_base  =>'/opt/apache-tomcat/tomcat',
}
     because the service named restart is running, not default, so i can't stop the tomcat service. so i want to know how to restart tomcat  just using only one kick command.
--
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/8ce7092e-c16c-423f-b7c9-81976916e795%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages