Issue #1048 has been updated by Andrew Parker.
Description updated
Status changed from Accepted to Closed
This appears to work as of Puppet 3.2.1:
<pre>
[vagrant@localhost ~]$ puppet --version
3.2.1
[vagrant@localhost ~]$ cat t.pp
$a = [[1, 2], [3, 4]]
notice(inline_template("<%= @a.inspect %>"))
notice($a[0][1])
[vagrant@localhost ~]$ puppet apply t.pp
Warning: Could not retrieve fact fqdn
Notice: Scope(Class[main]): [["1", "2"], ["3", "4"]]
Notice: Scope(Class[main]): 2
Notice: Finished catalog run in 0.03 seconds
[vagrant@localhost ~]$
</pre>
----------------------------------------
Feature #1048: can't build an array of arrays directly
https://projects.puppetlabs.com/issues/1048#change-91924
* Author: Martha Greenberg
* Status: Closed
* Priority: Normal
* Assignee:
* Category: language
* Target version:
* Affected Puppet version: 0.24.8
* Keywords:
* Branch:
----------------------------------------
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]).
<pre>
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
</pre>
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.