I like Chef, but some aspects of its internal kitchenary are pretty poorly documented (or I’m not good enough with Chef to understand why it should behave this exact way).
I’ve hit an annoying problem trying to fix library in a chef cookbook:
I had an attribute assigned in attribute file vault-cookbook/attributes/default.rb:
1 2 3
and override in recipe vault-cookbook/recipes/some_recipe.rb:
1 2 3
search_node() function is called from some_recipe.rb and described in a library vault-cookbook/libraries/library.rb:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
search_node() function gets vault name and performs some actions with nodes in this vault.
Now the magic
Guess if two log resource calls in library return same results for same node. Hell no!
this is ok, override works. But
override does not work because override from the recipe is not being applied to node objects found during search, they have vanilla set of attributes.
So if you want to avoid pitfalls keep your attributes in attribute files/roles/environments, not in recipes.
Just to be clear, mentioned issue appies to Chef 11, didn’t test on other versions.