I'm sure I'm doing something silly here, but I'm struggling to pass an array variable to a parameterized class and have it stay as an array:
# cat modules/testmodule/manifests/init.pp
class testmodule($array1) {
file {'/tmp/testmodule' :
content => template('testmodule/testmodule.erb'),
}
}
# cat manifests/nodes/site.pp
node 'testclient' {
$myarray = ['aaa','bbb']
class { "testmodule":
array1 => [$myarray],
}
}
# cat modules/testmodule/templates/testmodule.erb
<% array1.each do |val| -%>
array1 val: <%= val %>
<% end -%>
<puppet run>
# cat /tmp/testmodule
array1 val: aaabbb
i.e. the class does not think $array1 is an array any more. However if I change the node config to set the parameter as an array explicitly:
# cat manifests/nodes/site.pp
node 'testclient' {
class { "testmodule":
array1 => ['aaa','bbb'],
}
}
<puppet run>
# cat /tmp/testmodule
array1 val: aaa
array1 val: bbb
Its not unreasonable to try and pass an array as a variable is it?
Cheers,
Tom.