Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer 1

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.

http://foodfightshow.org/2013/06/episode-53-chef-internals-with-dan-deleo.html

share|improve this answer
add comment

Your Answer

 
discard

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.