Chef dynamically configures software and hosts, and a large part of configuring UNIX-based systems and software involves configuration files. Chef provides a straightforward mechanism to generate configuration files that make it easy to combine configuration data with template files to produce the final configuration files on hosts. These templates are stored in the templates
directory inside of a cookbook and use the ERB template language, which is a popular and easy-to-use Ruby-based template language.
Without templates, your mechanism to generate configuration files would probably look something like this:
File.open(local_filename, 'w') do |f| f.write("<VirtualHost *:#{node['app]['port']}") ... f.write("</VirtualHost>") end
This should be avoided for a number of reasons. First, writing configuration data this way would most likely make your recipe very cluttered and lengthy. Secondly, and more importantly, it violates Chef's declarative nature...