I have a following ruby template
interface <%= @interface %>
state <%= @state %>
priority <%= @priority %>
virtual_router_id 1
unicast_src_ip <%= @ipaddress_interface %>
at unicast_src_ip I would add the @interface-s ip address. the interface name is dynamic. So if I get eth0 in @interface the @ipadress_interface should be the ip of eth0 (@ipaddress_eth0). IF I predefine the name of the NIC like nic01. The @ipadress_nic01 works like a charm. But unfortunately I know the if name only when the puppet runs
You can access dynamically-determined variables by using the
scopeobject exposed to ERB scriptlets. It takes the name of the variable you want to access as a string, which can be computed at runtime in any of the ways that Ruby affords. Example: