class ChefCLI::PolicyfileCompiler
def install
def install ensure_cache_dir_exists cookbook_and_recipe_list = combined_run_lists.map(&:name).map do |recipe_spec| cookbook, _separator, recipe = recipe_spec.partition("::") recipe = "default" if recipe.empty? [cookbook, recipe] end missing_recipes_by_cb_spec = {} graph_solution.each do |cookbook_name, version| spec = cookbook_location_spec_for(cookbook_name) if spec.nil? || !spec.version_fixed? spec = create_spec_for_cookbook(cookbook_name, version) install_report.installing_cookbook(spec) spec.ensure_cached end required_recipes = cookbook_and_recipe_list.select { |cb_name, _recipe| cb_name == spec.name } missing_recipes = required_recipes.select { |_cb_name, recipe| !spec.cookbook_has_recipe?(recipe) } unless missing_recipes.empty? missing_recipes_by_cb_spec[spec] = missing_recipes end end unless missing_recipes_by_cb_spec.empty? message = "The installed cookbooks do not contain all the recipes required by your run list(s):\n" missing_recipes_by_cb_spec.each do |spec, missing_items| message << "#{spec}\nis missing the following required recipes:\n" missing_items.each { |_cb, recipe| message << "* #{recipe}\n" } end message << "\n" message << "You may have specified an incorrect recipe in your run list,\nor this recipe may not be available in that version of the cookbook\n" raise CookbookDoesNotContainRequiredRecipe, message end end