InterviewSolution
| 1. |
What is the purpose of “include_recipe” directive in Chef? |
|
Answer» include_recipe METHOD is used to include one or more recipes from cookbooks. It might be recipes from the same cookbook or dependent cookbooks. The syntax for the include_recipe method is as follows: include_recipe <Recipe name with the cookbook>For eg : include_recipe 'apache2::mod_ssl'includes all resources from the “mod_ssl.rb” file in “apache2” cookbook to our current recipe where the “include_recipe” directive is specified. If same recipes are INCLUDED multiple times using “include_recipe” directive method, only the FIRST is included and rest is neglected.”include_recipe” directive is considered better practice than specifying the recipe in the run list especially when one cookbook depends on another cookbook. This also lessens the burdens of running the dependent cookbooks first by specifying it first in the run list of every Chef node. In the CASE of wrapper cookbooks “include_recipe” directive is used to include functionalities from the dependent cookbooks. If it’s not specified but the dependent cookbooks are specified in the depends section of “metadata.rb” file, an error OCCURS. |
|