puppet-epp - Man Page

Interact directly with the EPP template parser/renderer.

Synopsis

puppet epp action

Options

Note that any setting that´s valid in the configuration file is also a valid long argument, although it may or may not be relevant to the present action. For example, server and run_mode are valid settings, so you can specify --server <servername>, or --run_mode <runmode> as an argument.

See the configuration file documentation at https://puppet.com/docs/puppet/latest/configuration.html for the full list of acceptable parameters. A commented list of all configuration options can also be generated by running puppet with --genconfig.

--render-as FORMAT

The format in which to render output. The most common formats are json, s (string), yaml, and console, but other options such as dot are sometimes available.

--verbose

Whether to log verbosely.

--debug

Whether to log debug information.

Actions

The output will be "pretty printed" when the option --pretty is given together with --format ´pn´ or ´json´. This option has no effect on the ´old´ format.

The command accepts one or more templates (.epp) files, or an -e followed by the template source text. The given templates can be paths to template files, or references to templates in modules when given on the form modulename/template-name.epp. If no arguments are given, the stdin is read (unless it is attached to a terminal)

If multiple templates are given, they are separated with a header indicating the name of the template. This can be suppressed with the option --no-header. The option --[no-]header has no effect when a single template is dumped.

When debugging the epp parser itself, it may be useful to suppress the validation step with the --no-validate option to observe what the parser produced from the given source.

This command ignores the --render-as setting/option.

Options --e <source> - Dump one epp source expression given on the command line.

--format <old, pn, or json> - Get result in ´old´ (deprecated format), ´pn´ (new format), or ´json´ (new format in JSON).

--[no-]header - Whether or not to show a file name header between files.

--pretty - Pretty print output. Only applicable together with --format pn or json

--[no-]validate - Whether or not to validate the parsed result, if no-validate only syntax errors are reported.

RETURNS

A dump of the resulting AST model unless there are syntax or validation errors.

Examples

render

Render the template in module ´mymodule´ called ´mytemplate.epp´, and give it two arguments a and b:

$ puppet epp render mymodule/mytemplate.epp --values ´{a => 10, b => 20}´

Render a template using an absolute path:

$ puppet epp render /tmp/testing/mytemplate.epp --values ´{a => 10, b => 20}´

Render a template with data from a .pp file:

$ puppet epp render /tmp/testing/mytemplate.epp --values_file mydata.pp

Render a template with data from a .pp file and override one value on the command line:

$ puppet epp render /tmp/testing/mytemplate.epp --values_file mydata.pp --values ´{a=>10}´

Render from STDIN:

$ cat template.epp | puppet epp render --values ´{a => 10, b => 20}´

Set variables in a .pp file and render a template that uses variable references:

# data.pp file
$greeted = ´a global var´
undef

$ puppet epp render -e ´hello <%= $greeted %>´ --values_file data.pp

Render a template that outputs a fact:

$ facter --yaml > data.yaml
$ puppet epp render -e ´<% $facts[osfamily] %>´ --facts data.yaml

validate

Validate the template ´template.epp´ in module ´mymodule´:

$ puppet epp validate mymodule/template.epp

Validate two arbitrary template files:

$ puppet epp validate mymodule/template1.epp yourmodule/something.epp

Validate a template somewhere in the file system:

  $ puppet epp validate /tmp/testing/template1.epp

Validate a template against a file relative to the current directory:

 $ puppet epp validate template1.epp
 $ puppet epp validate ./template1.epp

Validate from STDIN:

$ cat template.epp | puppet epp validate

Continue on error to see errors for all templates:

$ puppet epp validate mymodule/template1.epp mymodule/template2.epp --continue_on_error

Info

February 2024 Puppet, Inc. Puppet manual