Ask Your Question
2

What can I do with erb templates in Puppet?

asked 2013-01-17 13:07:12 -0500

ramindk gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2013-01-17 13:30:05 -0500

ramindk gravatar image

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)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-01-17 13:07:12 -0500

Seen: 14,491 times

Last updated: Jan 17 '13