Leveraging the new template engine
In Chapter 6, Leveraging the Full Toolset of the Language, we introduced templates and the ERB template engine. In Puppet 4, an alternative was added: the EPP template engine. The major differences between the template engines are as follows:
In ERB templates, you cannot specify a variable in Puppet syntax (
$variable_name
)ERB templates will not accept parameters
In EPP templates, you will use the Puppet DSL syntax instead of Ruby syntax
The EPP template engine requires scoped variables from modules:
# motd file – managed by Puppet This system is running on <%= $::operatingsystem %>
The manifest defines the following local variable: <%= $motd::local_variable %>
. The EPP templates also have a unique extension; they can take typed parameters. To make use of this, a template has to start with a parameter declaration block:
<%- | String $local_variable, Array $local_array | -%>
These parameters are not like variables from Puppet manifests....