Georgi Tenev
Georgi Tenev

Reputation: 436

Chef cookbook not seeing overridden attributes in another cookbook

I have a run_list like this [ recipe["git_deploy"], recipe["my_role_cookbook"] ]
I set attributes that git_deploy needs in the default.rb recipe of my_role_cookbook. However, the git_deploy doesn't get these attributes. If I put the attribute needed by git_deploy in my_role_cookbook/attributes/default.rb, then it works. If I put lazy evaluation in git_deploy - it works as well.
I don't get why it doesn't work if I use node.override in the my_rolecook_book/recipes/default.rb

The bigger picture: I have three environments, and in the role file of my_role, I have env_run_lists like this:

"production" => ["recipe[git_deploy]","recipe[my_role]"],
"staging" =>["recipe[git_deploy]","recipe[my_role]"],
"develop" => ["recipe[my_role]"]

EDIT
After using debug_value in both cookbooks:

Upvotes: 0

Views: 705

Answers (1)

Martin
Martin

Reputation: 2825

All files inside attributes/* are merged and evaluated before any recipes run. Since you've put git_deploy first on your runlist, it's recipes run before yours. You must use attribute files in order to get your attributes injected before git deploy's recipes, and then your recipe, runs. Or put git_deploy as an include from your recipe.

Here's a link with more on how attribute files work.

Upvotes: 0

Related Questions