Templates (EPP/ERB)
Generate config from data.
Templates render config files from data, and Puppet has two engines: EPP (Embedded Puppet, the modern choice, using Puppet syntax and typed parameters) and ERB (Embedded Ruby, older). You pass a parameter hash to epp() and reference values in the template; the rendered result becomes a file resource’s content. Same pattern as Ansible/Chef templating — one template plus per-node data replaces many hand-edited files.
<%- | Integer $workers, Integer $port | -%>worker_processes <%= $workers %>;http {server {listen <%= $port %>;server_name <%= $facts['networking']['fqdn'] %>;}}
file { '/etc/nginx/nginx.conf':ensure => file,content => epp('nginx/nginx.conf.epp', { 'workers' => 4, 'port' => 8080 }),notify => Service['nginx'],}
EPP over ERB
Prefer EPP for new code: it uses the Puppet language you already know (no context-switch to Ruby), declares its parameters with types at the top (so a missing or wrong-typed value fails clearly), and keeps templates consistent with manifests. ERB still appears in older modules and works fine, but EPP’s typed parameter list makes templates safer and self-documenting.