Using templates

Configuration Management is all about configuring your hosts well. Usually, configuration is carried out by using configuration files. Chef's template resource allows you to recreate these configuration files with dynamic values that are driven by the attributes we discussed so far in this chapter.

You can retrieve dynamic values from data bags, attributes, or even calculate them on the fly before passing them into a template.

Getting ready

Make sure you have a cookbook called my_cookbook and that the run_list of your node includes my_cookbook, as described in Creating and using cookbooks recipe in Chapter 1, Chef Infrastructure.

How to do it...

Let's see how to create and use a template to dynamically generate a file on your node: ...

Get Chef Infrastructure Automation Cookbook - Second Edition 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.