How to set a ruby variable on erb template
I'm trying to do set a variable on erb template. I explain with an example.
I create a vhost file for apache.
I have many server level : dev / int / prd, I set the $server_level on nodes.pp
And I want set the vhost IP on the erb template. The IP depends of the level, and the IP is set by facter. Like this :
<% if @server_level == "dev" %> <% @IP_site=@ipaddress_eth0%><% end %> <% if @server_level == "int" %> <% @IP_site=@ipaddress_eth1%><% end %> <% if @server_level == "prd" %> <% @IP_site=@ipaddress_eth2%><% end %>
Goal is to use on the erb file the IP_site variable and not do this if statement each time I want to print the IP.
But the expression I wrote before is wrong and I'm not à rubyman... Can you help me?
Thanks a lot!