On Feb 23, 2:44 pm, "M. Piscaer" <deb...@masterpe.nl> wrote: > Thanks for the response, I see that I made an typo.. > > The parameter nodes_data needs to be node_data as I have corrected > below. But the error stands. > > -------------- testnode.pp -------------- > > node testnode { > class { 'testclass': > node_data => { > 'node1' => { 'server' => 'node1.some.domain.com', 'port' > => '2560' }, > 'node2' => { 'server' => 'node2.another.domain.com', > 'port' => '2564' }, > 'node3' => { 'server' => 'node3.some.domain.com', 'port' > => '2564' } > } > } > > } > > -------------- testclass.pp -------------- > class testclass ( $node_data ) { > node_data += { > 'node4' => { 'server' => 'node4.another.domain.com', 'port' > => '2564' }, > 'node5' => { 'server' => 'node5.some.domain.com', 'port' => > '2564' } > } > > class { 'moduletest::test': > module_variable => $node_data > } > > } > > ------------------------------------------ > > When delete the rows: > > node_data += { > 'node4' => { 'server' => 'node4.another.domain.com', 'port' > => '2564' }, > 'node5' => { 'server' => 'node5.some.domain.com', 'port' => > '2564' } > } > > everything works fine. But then I still have the problem how to make the > settings that needs to be global and node specific at one hash?
Puppet does not allow you to redefine a variable one it is set. There are a couple of limited ways in which you can make it *appear* to do so, but those are an illusions. In your case, the $node_data variable is a parameter to the class so it's value is set according to the class's declaration. You cannot thereafter change it, but you could create a new variable that contains the contents of node_data plus the additional data. I think it's tricky to do that with a hash, though -- you might need to create a custom function. A technically superior solution, however, would be to use hiera for this problem. Aside from the fact that hiera is an all-around better solution for class data than is the current implementation of class parameters, hiera also has particular support for combining data from multiple levels of your data hierarchy. That appears to be exactly what you're looking for. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.