On Tue, Jul 24, 2012 at 08:08:30AM -0700, earthgecko wrote:
> Quick erb question:
>
> Can you use a if val in an each do iteration? And if so... how :/ If
> someone knows and is kind enough to shed some light.
>
> Trying to figure what will work and the following do NOT work.
>
> <% hosts.each do |val| %><% if val != "<%= hostname %>" %> host (<%= val
> %>);<% end %><% end %>
>
> <% hosts.each do |val| %><% if "<%= val %>" != "<%= hostname %>" %> host
> (<%= val %>);<% end %><% end %>
>
> <% hosts.each do |val| %><% if <%= val %> != "<%= hostname %>" %> host
> (<%= val %>);<% end %><% end %>
>
> All error with something similar to:
>
> syntax error, unexpected $undefined, expecting kTHEN or ':' or '\n' or ';'
> ...= hostname ; _erbout.concat "\" %> host ("; _erbout.concat...
> ^
> .....cfg.erb:15: syntax error, unexpected kEND, expecting $end
> ...rbout.concat ");"; end ; end ; _erbout.concat "\n key /et...
>
> Thanks in advance..
Haven't tested it but does
<% @hosts.reject { |h| h == @hostname }.each do |host| -%>
<%= host %>
<% end -%>
work for you?
-Stefan
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.