refreshonly on exec resource not working on file change

asked 2016-06-23 06:56:21 -0600

Mr_Sharma gravatar image

I have two config files and based on that I want to refresh a script(stop and start) whenever there is a change in either of the files. Also, the script should not get refreshed if there is no change in the file. I have written following code but not working as expected:

 #configure activemq.xml
 file { "$home_dir/$install_dir/conf/activemq.xml":
   ensure       => present,
   owner        => $amq_user,
   group        => $amq_group,
   content      => template('activemq/activemq.xml.erb'),
   audit        => content,
   notify       => Exec['serviceStop'],

#configure jetty.xml
 file { "$home_dir/$install_dir/conf/jetty.xml":
   ensure  => present,
   owner   => $amq_user,
   group   => $amq_group,
   content => template('activemq/jetty.xml.erb'),
   audit   => content,
   notify  => Exec['serviceStop'],

#stop activemq service
 exec {'serviceStop':
   command => "$home_dir/$install_dir/bin/activemq stop",
   user    => $amq_user,
   group   => $amq_group,
   refresh => true,
   notify  => Exec['serviceStart'],
   onlyif  => 'ps -ef | grep -v grep | grep activemq 2>/dev/null',

#start activemq service
 exec {'serviceStart':
   command     => "$home_dir/$install_dir/bin/activemq start",
   user        => $amq_user,
   group       => $amq_group,
   refreshonly => true,
   unless      => 'ps -ef | grep -v grep | grep activemq 2>/dev/null',

Service is getting stopped and started every time. How can we control them after a file change? Also, refresh => true is reporting an error: Error: Failed to apply catalog: no implicit conversion of true into String

Thanks in advance.

edit retag flag offensive close merge delete


should that be refreshonly => true ? the 'refresh' parameter is what is used for a refresh command that differs from the regular command.

DarylW gravatar imageDarylW ( 2016-06-23 20:26:21 -0600 )edit

Thanks for the pointer. Now the only problem is: when I am running agent 2nd time after change in the file, activemq services getting restarted due to "audit change: previously recorded value .....". Can we control this and skip the agent run if my file is not getting changes in further runs?

Mr_Sharma gravatar imageMr_Sharma ( 2016-06-24 02:22:19 -0600 )edit

any idea??

Mr_Sharma gravatar imageMr_Sharma ( 2016-07-04 03:09:16 -0600 )edit

Is the problem that the xml file is being modified by the application, and puppet keeps returning it to the way puppet expects it to be setup?

DarylW gravatar imageDarylW ( 2016-07-04 09:57:56 -0600 )edit

It also seems like you are trying to recreate starting and stopping of a service, albiet via a script. It may be better to explicitly use the 'base' provider for the service type and give your commands..

DarylW gravatar imageDarylW ( 2016-07-04 09:59:22 -0600 )edit