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


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

Makes sense.  Thanks, will give this a try.

-n



-----Daniel DeLeo ">< > wrote: -----
To: ">
From: Daniel DeLeo < >
Sent by: Daniel DeLeo < >
Date: 07/23/2012 02:38PM
Subject: [chef] Re: Comparing the checksum of a cookbook_file in an non cookbook_file resource


On Monday, July 23, 2012 at 8:15 AM, "> wrote:

> 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 | "> ( ">mailto: )

You want to chain the resources together with notifications:  

http://wiki.opscode.com/display/chef/Resources#Resources-Notifications

Then you probably also want to use `action :nothing` on the other resources.

--  
Dan DeLeo

> >



Archive powered by MHonArc 2.6.16.

§