[chef] Re: Re: good example of chef definitions ? need help with issue below


Chronological Thread 
  • From: "steve ." < >
  • To: " " < >
  • Subject: [chef] Re: Re: good example of chef definitions ? need help with issue below
  • Date: Fri, 4 Oct 2013 10:06:00 -0700

My two cents:

When asking yourself if you should use a definition, remember that it's a macro.  You may invoke it like a resource, but it is not a resource.  Are you only looking to save yourself some typing or are you looking to do something more?

If all you want to do is blast 26 Java apps out in the same way onto a node, you could do that with a macro.  So a define's probably a good fit for that.

If you are looking to ultimately _manage_ those apps (and, say, have their config file changes trigger redeploys/restarts), but right now you just need to deploy them, you might want to consider throwing all that into a LWRP (or HWRP, if you fear not the Ruby).  You'll probably end up doing it eventually anyway, so you might as well start as you mean to go on.


On Fri, Oct 4, 2013 at 1:42 AM, Andy Gale < " target="_blank"> > wrote:
Good example of a definition here :) 


LWRPs are where it's at nowadays though definitions are a bit easier to understand I think.

If people feel strongly about it though, convert that to a LWRP and I'll be happy to update the book!


On Fri, Oct 4, 2013 at 8:24 AM, Manoj Thakkar < " target="_blank"> > wrote:
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 a use case on how to sue it

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
  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





--
Andy Gale
http://andy-gale.com
http://twitter.com/andygale




Archive powered by MHonArc 2.6.16.

§