Ask Your Question

How to check if the war file deployed by puppetlabs-tomcat module is new

asked 2016-08-05 10:32:32 -0500

updated 2016-08-05 13:12:31 -0500

I need to send an email only when the tomcat deployment of war file is complete and the war file is newer than what was before. How do i do that? I have the mail command working but the mail part sends an email every time the deploy module runs, it should be restricted to send email only when the war file changes in tomcat::catalina::base/webapps/filename.war.

Please provide examples. Many thanks in advance.

edit retag flag offensive close merge delete


I am not able to provide you with an example right now. But, probably you can try with mtime or audit in file resource to check if you are getting a newer file on your target machine whose content is different than the older file.

rajeevsharma gravatar imagerajeevsharma ( 2016-08-05 12:50:42 -0500 )edit

On First execution I get an undefined method ‘notice’ for nil:NilClass Upon consecutive executions,it works fine and sends email only if war is changed and does not error out.Any idea why it throws this error the first time alone? I think it tries to audit the contents before the file was created.

Redsmile gravatar imageRedsmile ( 2016-08-08 13:33:25 -0500 )edit

1 Answer

Sort by » oldest newest most voted

answered 2016-08-06 12:43:33 -0500

JohnsonEarls gravatar image

By using a subscription, you can send an email whenever a File resource changes the contents of a file.

file { "${tomcat_appbase}/myapp.war":
    ensure => present ,
    source => "puppet:///modules/${module_name}/myapp.war" ,
    # other File attributes as needed

exec { "command-to-send-email":
    subscribe => File["${tomcat_appbase}/myapp.war"] ,
    # other Exec attributes as needed
edit flag offensive delete link more


Thanks. But the requirement is to have a remote_file and not a file resource. And the name of the remote_file changes dynamically based on the App and not a static name.

Redsmile gravatar imageRedsmile ( 2016-08-08 13:25:29 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-08-05 10:32:32 -0500

Seen: 77 times

Last updated: Aug 06 '16