Ask Your Question
1

`if else` statement in erb template

asked 2013-10-02 13:11:44 -0500

spuder gravatar image

updated 2013-10-13 23:24:21 -0500

How can I modify a config file based on certain logic?

Example:

cat templates/foo.erb
if somelcass::someparameter == true
    bar = 42
else
    bar = 0
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2013-10-02 13:15:34 -0500

spuder gravatar image

puppet templates follow the erb templating standard.

The puppet documentation contains an example of how to do a simple if statement.

<% if broadcast != "NONE" %>       
 broadcast <%= broadcast %> 
<% end %>

To do an if/else statement, simply add <% else %>

<% if @someclass::someparameter != true %>
  bar = 42
<% else %> 
   bar = 0
<% end %>

http://stackoverflow.com/questions/6932663/whats-wrong-with-my-simple-if-else

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

1 follower

Stats

Asked: 2013-10-02 13:11:44 -0500

Seen: 51,277 times

Last updated: Oct 13 '13