if you do

  $var = [[1,2,3], [4,5,6]]

$var will be set to [1,2,3,4,5,6].  you can observe this with a template
like

  <% var.each do |el| -%>
  array element: <%= el %>
  <% end -%>

on the other hand,

  $a = [1,2,3]
  $b = [4,5,6]
  $var = [$a, $b]

will preserve the arrays within the array, which means you can do a
nested loop in your template:

  <% var.each do |arr| -%>
  array {
  <%   arr.each do |el| -%>
    <%= el %>
  <% end -%>
  }
  <% end -%>

defining lots of "dummy" variables will just make the config less easy
to read, so the current best workaround is to use a string and split it
on some character which hopefully won't be used in any of the values.
ugly.

question: does anyone really depend on this flattening of arrays which
are specified as immediate values, or could this behaviour change?

this issue is related to http://projects.reductivelabs.com/issues/2226


I tried to work around the problem by defining a function which would do
this for me, e.g.,

  $var = concat([1,2,3], [4,5,6])

unfortunately, even though the function works for simple values, with
these immediate array values the parser barfs:

  Syntax error at '['; expected ']'


I'm using 0.24.8, please let me know if this behaviour has changed in
0.25.x.
-- 
Kjetil T. Homme
Redpill Linpro AS - Changing the game

--

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.


Reply via email to