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?

masegaloeh
  • 18,236
  • 10
  • 57
  • 106
Mediocre Gopher
  • 803
  • 1
  • 13
  • 24

1 Answers1

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.

Kyle
  • 1,589
  • 9
  • 14
  • 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. – Mediocre Gopher Jul 15 '11 at 16:24
  • Just tested it, definitely works (not that I doubted you :P) – Mediocre Gopher Jul 15 '11 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 '11 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 '11 at 03:22