[chef] Comparing the checksum of a cookbook_file in an non cookbook_file resource


Chronological Thread 
  • From:
  • To:
  • Subject: [chef] Comparing the checksum of a cookbook_file in an non cookbook_file resource
  • Date: Mon, 23 Jul 2012 11:15:42 -0400
  • Importance: Normal

Hi All,

We have a deployment scenario where we are deploying a war to a Tomcat server, and if a developer or ops person is in the exploded war directory at the time, tomcat fails to redeploy the war file. 
We are not using the application cookbook.

What I would like to do is add a file and directory resource to delete the war file and exploded war directory if the war file's checksum has changed prior to the cookbook_file line.  I am assuming that the cookbook_file resource always uses the checksum by default. Recipe snippet below:

#Caching
file "#{node[:tomcat][:webapp_dir]}/perc-caching.war" do
  action :delete
  only_if [checksum of new cookbook file doesn't match installed cookbook file]
end

directory "#{node[:tomcat][:webapp_dir]}/perc-caching" do
  action :delete
  recursive true
  only_if [checksum of new cookbook file doesn't match installed cookbook file]
end

cookbook_file "#{node[:tomcat][:webapp_dir]}/perc-caching.war" do
    source "perc-caching.war"
    backup false
    owner "#{node[:tomcat][:user]}"
    group "#{node[:tomcat][:group]}"
   
only_if [is this implied by the cookbook_file resource?]
end

Is there a way to get the checksum of the cookbook_file that is currently installed and comparing it to the checksum of the new cookbook file so that the delete actions on the file and directory resources only run when the file has changed?


Any help,tips, comments, appreciated.

Thanks!

Nate Chadwick Percussion Software
(O) 781-835-1356  |  ">


See for yourself what all the fuss is about—watch a demo now!





Archive powered by MHonArc 2.6.16.

§