Help changing recipe to definition


#1

Hi,

I am looking for some good example for chef definition, or may be someone
can help me change my recipe in to a definition so that i can use it in any
recipe.

  • this is the use case , i have this tomcat web deployment for 10+ wars
    since the deployment mechanism remains the same for every war i think a
    definition is the right thing to do, correct me if i am wrong

here is my recipe .Please help change it to a definition and an example of
a recipe on how to use it, appreciate your help

cookbook_file
"#{node[:tcat][:base_dir]}/webapps/#{node[:tcat][:war_name]}.war" do
source "#{node[:tcat][:war_name]}-#{node[:file][:version]}.war"
mode 0777
owner "deploy"
group "deploy"
end
remote_file “#{node[:tcat][:base_dir]}/#{node[:tcat][:env]}-config.zip” do
source "
http://sds-repo-dev.qdc.intuit.com:8082/nexus/service/local/artifact/maven/redirect?r=IIT.BOS-snapshots&g=com.intuit.platform.services.ebs.ecommerce&a=#{node[:tcat][:env]}-config&c=bin&e=zip&v=LATEST
"
mode '777’
owner "deploy"
notifies :run, “bash[unzip_file]”, :immediately
end

bash “unzip_file” do
cwd "#{node[:tcat][:base_dir]}"
code <<-EOS
pwd
unzip "#{node[:tcat][:env]}-config.zip"
EOS
action :nothing
end

link “#{node[:tcat][:base_dir]}/cas-config” do
to "#{node[:tcat][:env]}-config"
end