What can I do with erb templates in Puppet?
Most of the examples of templates in Puppet are quite simple. What are some interesting or complex uses of template that Puppet users find useful.
Puppet uses Ruby erb template which are quite powerful. Text between <% %> is executed as Ruby code. Text between <%= %> will be interpolated as a variable.
This would write the operating system fact to a file
<%= @operatingsystem %>
This would do it twice with on a new line at the end because of the -%> in the first instance.
<%= @operatingsystem -%> <%= @operatingsystem %>
If the value you want is not a fact or local variable, you'll need to look it up like this.
<%= scope.lookupvar('rvm::data::ruby_version') %>
You can of course manipulate the data in each. Keep in mind that all facts are strings ... (more)
Asked: 2013-01-17 13:07:12 -0500
Seen: 13,922 times
Last updated: Jan 17 '13