Okay, I got it now.

                        <% if @ip_xforward != '' %>
                                <% if ip_xforward.is_a? Array -%>
                                        <% ip_xforward.map do |value| -%>
                                                <%= "\t\tSetEnvIf 
X-Forwarded-For ^(" + value.gsub('.', '\.') + ".*) AllowIP\n"  -%>
                                        <% end -%>
                                <% else %>
                                        <%= "  SetEnvIF X-Forwarded-For 
 ^(#{ip_xforward}) AllowIP" -%>
                                <% end -%>
                        <% end -%>

So a array of ip address in the manifests results in 
            SetEnvIf X-Forwarded-For ^(13\.74\.8\.23.*) AllowIP
            SetEnvIf X-Forwarded-For ^(5\.63\.23\.53.*) AllowIP



Thanks!

Regards,
Björn


Am Freitag, 22. Mai 2015 14:21:26 UTC+2 schrieb Henrik Lindberg:
>
> On 2015-22-05 11:08, Gabriel Filion wrote: 
> > On 20/05/15 09:04 AM, Björn wrote: 
> >> I tried it with regsubst, but without success: 
> >> | 
> >> <%ip_xforward.each do|name|-%><%="\t\tSetEnvIF X-Forwarded-For 
> >> ^(regsubst(#{name}, '\.','\\.')) AllowIP\n"%><%end-%> 
> >> | 
> > 
> > maybe you need to call the function outside of the string. e.g.: 
> > 
> > <%= "\t\tSetEnvIf X-Forwarded-For ^(" + regsubst(name, '\.','\\.') + ") 
> > AllowIP\n"%> 
> > 
>
> Note that the each method returns the original LHS not the string. Also, 
> the substitution inside the string is not code that gets evaluation, you 
> need to interpolate it using #{} around the expression, or do a concat. 
>
> If you want to transform each, you should use the map function instead 
> of each - then the result is an array of each value returned from the 
> block. 
>
> Regards 
> - henrik 
>
> -- 
>
> Visit my Blog "Puppet on the Edge" 
> http://puppet-on-the-edge.blogspot.se/ 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/b32aa9ae-79a6-4480-9033-2ddcb981df63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to