Recipes are plain Ruby files. It is possible to use all of Ruby's language features inside your recipes. Most of the time, the built-in Ruby functionality is enough but sometimes you might want to use additional Ruby gems. Connecting to an external application via an API or accessing a MySQL database from within your recipe are examples of where you will need Ruby gems inside your recipes.
Chef lets you install Ruby gems from within a recipe, so that you can use them later.
Make sure you have a cookbook called my_cookbook
and that the run_list
of your node includes my_cookbook
, as described in the Creating and using cookbooks
recipe in Chapter 1, Chef Infrastructure.