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 [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/8ce7092e-c16c-423f-b7c9-81976916e795%40googlegroups.com > <https://groups.google.com/d/msgid/puppet-users/8ce7092e-c16c-423f-b7c9-81976916e795%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/545A909F.20700%40Alumni.TU-Berlin.de. For more options, visit https://groups.google.com/d/optout.
