Erb template puppet
For more information on how Puppet uses your personal information, see our privacy policy. Current version. EPP works with Puppet 4. Send feedback to the Docs team:. EPP is the preferred and safer method because it isolates environments. See EPP and environment isolation for more information.
Puppet passes data to templates via special objects and variables, which you can use in the tagged Ruby code to control the templates' output. The following table provides an overview of the main tag types used with ERB.
See the sections below for additional detail about each tag, including instructions on trimming whitespace and escaping special characters. I want to ERB tag syntax Insert the value of a single expression. For example, text surrounded by a tagged if statement only appears in the output if the condition is true.
An expression-printing tag inserts the value into the output. There are two ways to access variables in an ERB template: variable scope['variable'] and its older equivalent, scope. Using if statements The if To write a block of code in Ruby , use either do arguments Note that this is different from Puppet lambdas — but they work similarly. This method takes two arguments: The name of the function, as a string.
All arguments to the function, as an array. This must be an array even for one argument or zero arguments. This is a fake driver intended for backup and when no outside source of synchronized time is available. Evaluating ERB templates that are in a template file Put template files in the templates directory of a module.
To use a ERB template file, evaluate it with the template function. Send feedback to the Docs team:. See an issue? Execute an expression without inserting a value. Puppet includes the puppet epp command-line tool for EPP templates, while Ruby can check ERB syntax after trimming the template with its erb command.
The puppet epp command includes an action that checks EPP code for syntax problems. The command is silent on a successful validation. You can render EPP from the command line with puppet epp render. If Puppet can evaluate the template, it outputs the result. If your template relies on specific parameters or values to function, you can simulate those values by passing a hash to the --values option:.
You can use Ruby to check the syntax of ERB code by piping output from the erb command into ruby. Templates are more powerful than normal strings, and less powerful than modeling individual settings as resources. Strings in the Puppet language already allow you to interpolate variables and expressions into text.
0コメント