M. Piscaer
2012-Feb-22 07:21 UTC
[Puppet Users] Error 400 on SERVER: Cannot append, variable node_data is defined in this scope at
Hi, I have an problem that I can''t get resolved. I have an hash like www.krzywanski.net/archives/703. With this hash i whould like the add some extra hashes before passing to the module, i have tryed the code below. node testnode { class { ''testclass'': nodes_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'' } } } } 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 } } But then I get the error: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Cannot append, variable node_data is defined in this scope at /opt/puppet/env/manifests/classes/testclass.pp:1 on node testmp-test-04.intern warning: Not using cache on failed catalog err: Could not retrieve catalog; skipping run Without adding the information everything works fine. Kind regards, Michiel Piscaer -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Walter Heck
2012-Feb-23 20:04 UTC
Re: [Puppet Users] Error 400 on SERVER: Cannot append, variable node_data is defined in this scope at
Where you call the class you mention nodes_data, and inside the class it''s node_data. Unless this is not a one-to-one copy-paste that might be your problem? On Wed, Feb 22, 2012 at 15:21, M. Piscaer <debian@masterpe.nl> wrote:> Hi, > > I have an problem that I can''t get resolved. I have an hash like > www.krzywanski.net/archives/703. > > With this hash i whould like the add some extra hashes before passing to the > module, i have tryed the code below. > > > node testnode { > class { ''testclass'': > nodes_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'' } > } > } > } > > 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 > } > } > > But then I get the error: > > err: Could not retrieve catalog from remote server: Error 400 on SERVER: > Cannot append, variable node_data is defined in this scope at > /opt/puppet/env/manifests/classes/testclass.pp:1 on node > testmp-test-04.intern > warning: Not using cache on failed catalog > err: Could not retrieve catalog; skipping run > > Without adding the information everything works fine. > > > Kind regards, > > Michiel Piscaer > > -- > 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- Walter Heck -- follow @walterheck on twitter to see what I''m up to! -- Check out my new startup: Server Monitoring as a Service @ http://tribily.com Follow @tribily on Twitter and/or ''Like'' our Facebook page at http://www.facebook.com/tribily -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
M. Piscaer
2012-Feb-23 20:44 UTC
Re: [Puppet Users] Error 400 on SERVER: Cannot append, variable node_data is defined in this scope at
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? Kinds regards, Michiel Piscaer On 23-02-12 21:04, Walter Heck wrote:> Where you call the class you mention nodes_data, and inside the class > it''s node_data. Unless this is not a one-to-one copy-paste that might > be your problem? > > > > On Wed, Feb 22, 2012 at 15:21, M. Piscaer<debian@masterpe.nl> wrote: >> Hi, >> >> I have an problem that I can''t get resolved. I have an hash like >> www.krzywanski.net/archives/703. >> >> With this hash i whould like the add some extra hashes before passing to the >> module, i have tryed the code below. >> >> >> node testnode { >> class { ''testclass'': >> nodes_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'' } >> } >> } >> } >> >> 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 >> } >> } >> >> But then I get the error: >> >> err: Could not retrieve catalog from remote server: Error 400 on SERVER: >> Cannot append, variable node_data is defined in this scope at >> /opt/puppet/env/manifests/classes/testclass.pp:1 on node >> testmp-test-04.intern >> warning: Not using cache on failed catalog >> err: Could not retrieve catalog; skipping run >> >> Without adding the information everything works fine. >> >> >> Kind regards, >> >> Michiel Piscaer >> >> -- >> 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+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/puppet-users?hl=en. >> > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
jcbollinger
2012-Feb-24 14:23 UTC
[Puppet Users] Re: Error 400 on SERVER: Cannot append, variable node_data is defined in this scope at
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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.