Search code examples
rubychef-infrachef-recipecookbook

chef - using recipes from same cookbook


I have cookbook base and cookbook myapp

base has 2 recipes - my_java and java_with_custom_stuff

in java_with_custom_stuff I want to use the recipe for my_java (same cookbook). something like

include_recipe 'my_java'

bash 'custom stuff' do
...
end

in myapp I do include_recipe "base::java_with_custom_stuff"

yet it complains that it cannot find my_java

Is there a way to use a recipe from the same cookbook?


Solution

  • include_recipe uses the first part every time as the cookbook name. So you have to specify the cookbook - name + recipe name:

    include_recipe '::my_java' # works still after you rename your cookbook
    include_recipe 'base::my_java' # works only as long as your cookbook name is base