Nested arrays in puppet....

405 views
Skip to first unread message

Craig Dunn

unread,
Apr 7, 2009, 6:30:20 AM4/7/09
to puppet...@googlegroups.com

I'm trying to nest arrays within puppet to use in an ERB template... is
this something thats supported in puppet.

Im defining my variable as:

$var = [ [ foox, fooy ], [ barx, bary ] ]

Within my erb template, I'm doing:

var.each { |x,y|
%>
X: <%= x %>
Y: <%= y %>
<%
}
%>

This seems to work when I test it with a simple Ruby script, but when my
ERB template gets it from puppet it seems to have flattened the array,
any way to stop this from happening?

Cheers
Craig


Philip Zeyliger

unread,
Apr 7, 2009, 8:54:43 PM4/7/09
to puppet...@googlegroups.com
I haven't seen a way to do this, because puppet's configuration has limited datatypes.

To do something similar, I encoded the same data in strings.

I used this snippet in my manifest:

sources => ["key1/host1:1234", "key2/host2:1234"]

And this snippet in my template:

<%# syntax is "<name>/<source>" %>
<% sources.each do |source| -%>
data_source <%= source.split("/")[0] %> <%= source.split("/")[1] %>
<% end -%>

-- Philip
Reply all
Reply to author
Forward
0 new messages