レシピから同cookbook内の別レシピの呼ぶ


レシピから別のレシピを呼ぶ場合はinclude_recipeを使う

recipe/my_recipe.rb
include_recipe "other_cookbook::other_recipe"

同cookbook内の別レシピを呼ぶ場合も使えるが、foodcriticに引っかかる
FC007: Ensure recipe dependencies are reflected in cookbook metadata
http://www.foodcritic.io/#FC007
つまりinclude_recipeするcookbookはmetadataに依存性を書いとかなきゃいけない

ただmetadataに自身のcookbookをdependsするのもダメ
FC063: Cookbook incorrectly depends on itself
http://www.foodcritic.io/#FC063

これらのwarning回避するには、自身のcookbook名をハードコードするのではなく、変数を使う

recipe/my_recipe.rb
include_recipe "#{cookbook_name}::my_recipe"

参照