About parameters in cookbooks

Hi Chefs,

So far, I’ve only used the parameters/default.rb file for setting up cookbook parameters, and my use of it has stayed within the lines of “default[‘param’] = value”.

I’ve been wanting to understand better how to use them, and wanted to know what other forms are there for setting up parameters. More specifically:

  • Other than “default[‘param’]”, what other constructs can I use in a parameters file?

  • How do I set a parameter for a dependency – e.g. cookbook A depends on cookbook B, but B is a community cookbook. How do I set a B parameter in the A cookbook so that it gets used when the node is converged?

  • If I’m creating a wrapper cookbook (as described by Bryan Berry in his Gangnam Style post [1]), how and where should I set the generic cookbook’s parameters? (this is probably the same as the question above, so feel free to answer them as one if that’s the case)

  • What other files can go into the parameters directory, and how and when to use them?

Any other thoughts on the use of parameters, as well as good examples that do not follow “the norm”, would be welcome as well.

[1] http://devopsanywhere.blogspot.com.br/2012/11/how-to-write-reusable-chef-cookbooks.html


Cassiano Leal