Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 11 down vote accepted

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.

share|improve this answer
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 3:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.