Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 0.9.4
-
Fix Version/s: None
-
Component/s: Chef Client
-
Labels:None
Description
Recipes are only loaded once even when they depend (and will be different) based on data bag items. Loading them again (e.g. in a loop over data bag items) will produce debug messages like "I am not loading #{recipe_name}, because I have already seen it."
The cookbooks/application/recipes/default.rb code only works for one app in the apps databag:
search(:apps) do |app|
(app["server_roles"] & node.run_list.roles).each do |app_role|
app["type"][app_role].each do |thing|
node.run_state[:current_app] = app
include_recipe "application::#{thing}"
end
end
end
node.run_state.delete(:current_app
—
The 'application::#{thing}' recipes are included only once even though they will be different based on different values in the 'app' data bag item. To force including the recipe you need to do something like this:
node.run_state[:seen_recipes].delete("application::#{thing}")
include_recipe "application::#{thing}"
I consider this a workaround. It would be nicer to specify force loading recipes, e.g. like this:
include_recipe "application::#{thing}", :force => true
+1
Thanks for the workaround!