4

Basically I have a couple cookbooks I've written, and currently they all have the same definition file copied on each. Obviously this is a bad situation, as it makes adding new cookbooks more difficult, and changing that definition file requires changing three or four other files to be exactly the same.

Is there a way that, if I have a separate cookbook who's purpose is to basically just contain that definition, I can import that definition file into the recipes that need it?

1 Answer 1

12

Take a look at metadata: depends it will tell Chef to include the cookbook in the run list for this cookbook, and thus you will have the definition available. Just leave the default cookbook empty and it won't do anything.

4
  • Ah, I had seen that command, I thought it just told chef to send that cookbook along with the one that depends on it so it's recipes would be available, I didn't realize it would actually import the definitions as well. Jul 15, 2011 at 16:24
  • Just tested it, definitely works (not that I doubted you :P) Jul 15, 2011 at 16:51
  • Glad it works for ya! Its a shame the chef documentation is so sparse. I just recently figured that out myself.
    – Kyle
    Jul 15, 2011 at 16:58
  • I updated the wiki page linked in your answer to clarify that other things from cookbooks create dependencies and should be specified.
    – jtimberman
    Jul 24, 2011 at 3:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .