In a previous example we had Puppet deploy an Nginx virtual host file for the cat-pictures
application. In this case we simply used a file
resource with the cat-pictures.conf
file distributed from Puppet.
If we wanted to generalize this solution to manage many different websites, it would quickly become tedious to supply an almost identical virtual host file for each site, altering only the name and domain of the site.
What we would prefer is to give Puppet a template file into which it could just insert these variables for each different site. The template
function serves just this purpose. Anywhere you have multiple files that differ only slightly, or files that need to contain dynamic information, you can use a template.