Feature #1048

can't build an array of arrays directly

Added by Martha Greenberg over 4 years ago. Updated 9 months ago.

Status:Accepted Start date:
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:language
Target version:-
Affected Puppet version:0.24.8 Branch:
Keywords:
Votes: 3

Description

You should be able to create an array of arrays directly ([[1,2],[3,4]]). Right now, puppet flattens that out to a single array ([1,2,3,4]). Doing this via variables does work ($a=[1,2];$b=[3,4];$array=[$a,$b]).

het:/tmp# cat /tmp/test.erb
<% aliases.each do |src,dest| -%>
test <%= src %> foo <%= dest %>
<% end -%>
het:/tmp# cat /tmp/etest.pp
$aliases = [[[1" 3]["2]]
file { "/tmp/output":
        content => template("/tmp/test.erb")
}
het:/tmp# puppet etest.pp
notice: //File[/tmp/output]/content: created file with contents {md5}136e6a9ed28256274b16de7ba9e1d7e1
het:/tmp# cat /tmp/output
test /1 foo
test 3 foo
test /2 foo
test 5 foo
het:/tmp# cat /tmp/etest2.pp
$a1 = [r1]
$a2 = [r2]
$aliases = [$a1,$a2]
file { "/tmp/output":
        content => template("/tmp/test.erb")
}
het:/tmp# puppet etest2.pp
notice: //File[/tmp/output]/content: changed file contents from {md5}136e6a9ed28256274b16de7ba9e1d7e1 to {md5}3b6c1fb2cd842043cf66266f59cb2d88

het:/tmp# cat /tmp/output fg
test /1 foo 3
test /2 foo 5


History

Updated by Redmine Admin almost 4 years ago

  • Status changed from 1 to Accepted

Updated by James Turnbull almost 3 years ago

  • Assignee deleted (Puppet Community)
  • Affected Puppet version set to 0.24.8

Updated by James Turnbull 9 months ago

  • Target version deleted (4)

Also available in: Atom PDF