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

Here's what a chef cookbook looks like:

├── attributes
│   ├── default.rb
│   └── bla.rb
├── files
│   ├── default
│   │   └── some_file.txt
│   └── windows
│       └── some_file.txt
├── libraries
│   ├── mylib.rb
│   └── default.rb
├── providers
│   ├── default.rb
│   └── foo.rb
├── recipes
│   ├── bar.rb
│   └── default.rb
├── resources
│   ├── default.rb
│   └── foo.rb
└── templates
    ├── default
    │   └── some_template.erb
    └── windows
        └── some_template.erb

I went through the docs, but I'm still confused about how and when each part of a chef cookbook is loaded/executed, and whether it's automatic (and if so in what order?) or on-demand. Could you please provide a summary or point to one?

I'm specifically confused about the logic for loading files under the attributes, libraries, providers, recipes and resources directories. They all contain a default.rb file, but it seems that in some cases it's automatically loaded (for attributes, for example), and in some cases it is not (for recipes, for example). There's a page in the doc about the order in which attribute files are loaded, but it's not clear in what order within the attributes directory. It's not clear to me why you would want to have attribute files other than default.rb (it seems that most cookbooks only use default.rb). What would the use-case be?

Perhaps I should ask separate questions, but I thought it might be useful for other chef-newbies to have a summary here.

Thanks a lot.

share|improve this question

This is actually a fairly complex question and often the hardest part of Chef to wrap your brain around. I found this podcast very helpful.

share|improve this answer

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.