chef-infrachef-recipedatabags

Using multiple recipes in same cookbook


I have a chef cookbook with four recipes. Each recipe configures a web application:

myCookbook
   |
   |_ _ recipes
       |_ _ default.rb
       |_ _ app1.rb
       |_ _ app2.rb
       |_ _ app3.rb
       |_ _ app4.rb

I've configured this cookbook to update apps based on a default.rb recipe that just iterates over the other web app recipes and runs them. The cookbook is kicked off by updated web app version in a data bag.

Because I put all the apps into one cookbook, if I want to update one app then I have to update them all. I can manually override the runlist to just deploy one app, but is there a way to "knife diff" the data bag in the default recipe (or something like that) to only run the corresponding recipe of the web app version that was updated?


Solution

  • You would have to implement the diff yourself using a local copy for idempotence tracking. Overall I would recommend reworking your recipes to be idempotent and convergent themselves.