Issue #6744 has been updated by Walter Heck.
Category set to templates
Target version set to 2.7.x
Keywords set to erb, arrays
I'm running into this problem as well, and found out it works in later versions
of puppet. Just updating ehre for others to see.
Puppet 2.6.2:
<pre>
# puppet apply -e '$c = [[1,2,3],[4,5,6]] notice(inline_template("<% c.each do
|z| %><%= z[0] %>, <% end %>"))'
notice: Scope(Class[main]): 49, 50, 51, 52, 53, 54,
</pre>
in puppet 2.7.6 (possibly earlier 2.7.x versions as well), this works correctly:
<pre>
# puppet apply -e '$c = [[1,2,3],[4,5,6]] notice(inline_template("<% c.each do
|z| %><%= z[0] %>, <% end %>"))'
notice: Scope(Class[main]): 1, 4,
notice: Finished catalog run in 0.03 seconds</pre>
----------------------------------------
Bug #6744: Multidimensional Array passed to template will be flattened
https://projects.puppetlabs.com/issues/6744
Author: Daniel Grafe
Status: Closed
Priority: Normal
Assignee:
Category: templates
Target version: 2.7.x
Affected Puppet version: 2.6.5
Keywords: erb, arrays
Branch:
We are writing several routes like this:
define route::multiple( $routes) {
file { "routes":
name => $operatingsystem ? {
SLES => "/etc/sysconfig/network/routes",
RedHat =>
"/etc/sysconfig/network-scripts/routes"
},
ensure => present,
content => template("net/ifroute_multiple.erb"),
}
}
Calling the definition like that:
net::route::multiple { "Additional routes":
routes => [
[ '10.30.0.0',
'10.30.33.20', '255.255.255.0', 'bond0' ],
[ '10.30.32.0',
'239.30.10.2' ,'255.255.255.240', 'bond0' ],
[ '10.30.7.14',
'239.30.110.2','255.255.255.240', 'eth4' ],
[ '194.49.199.0',
'10.30.33.10', '255.255.255.0', 'bond0' ],
[ '194.49.239.0',
'10.30.33.10', '255.255.255.0', 'bond0' ]
]
}
The multidimensional array will be expanded in the template:
#######################################################
### /etc/sysconfig/network/routes (<%= name %>)
#######################################################
# destination gateway genmask device
<% routes.each do |r| -%>
<%= r[0] %> <%= r[1] %> <%= r[2] %> <%= r[3] %>
<% end-%>
With puppet Version 2.6.3 the result was a valid routes file with every line
defining a route. We have now moved to puppet 2.6.5 and the result is a file
with completely cluttered entries. The enclosing array seems to be "flattened",
it is no longer an array of arrays with 4 components each but it is just one
serialized array. Iterating this array as shown above resulst in misinterpreted
values:
#######################################################
### /etc/sysconfig/network/routes (Additional routes)
#######################################################
# destination gateway genmask device
49 48 46 51
49 48 46 51
50 53 53 46
98 111 110 100
--
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 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-bugs?hl=en.