Templates

As we mentioned earlier, templates are Embedded Ruby (ERB) templates, which can be used to generate configuration files based upon some variables and logic. These files may contain Ruby statements and expressions. To make use of templates, one has to use the template resource in a cookbook and specify in the source the path to the template itself. The template file is placed in the templates directory of a cookbook.

Unless you are creating your cookbooks manually, Knife will automatically take care of creating the templates directory structure. A template is stored in the cookbook_name/templates directory and is referenced by the template resource in the cookbook recipe. Generally, cookbooks are developed, keeping different platforms ...

Get Mastering Chef now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.