Rich Rauenzahn
2011-Feb-08 00:18 UTC
[Puppet Users] returning a hash (json object) from custom function?
We have a command line utility that queries a database to get certain facts about our hosts -- I wanted to write a custom function to obtain all of those facts at once. The tool outputs JSON and I wanted to take that output and return a hash back into puppet where I could access the facts like... $a = host_info() if $a[''in_maintenance''] == ''yes'' { } ... etc, etc. Right now I''m getting: can''t convert Array into String at ... Which I assume means that puppet is expecting a string back from the custom function. Maybe I just need to make a fact out of these instead and prefix them with foo_in_maintenance, etc., etc., etc., but I''d really rather use structured data. -- 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.
Rich Rauenzahn
2011-Feb-08 00:59 UTC
[Puppet Users] Re: returning a hash (json object) from custom function?
Ok, I was mistaken. Returning a hash works. It would be helpful if the ruby exceptions bubbled up to puppet reported the correct line number from the ruby source -- if that is possible. Rich On Mon, Feb 7, 2011 at 4:18 PM, Rich Rauenzahn <rrauenza@gmail.com> wrote:> We have a command line utility that queries a database to get certain > facts about our hosts -- I wanted to write a custom function to obtain > all of those facts at once. The tool outputs JSON and I wanted to > take that output and return a hash back into puppet where I could > access the facts like... > > $a = host_info() > > if $a[''in_maintenance''] == ''yes'' { > } ...-- 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.
Peter Meier
2011-Feb-10 16:35 UTC
Re: [Puppet Users] Re: returning a hash (json object) from custom function?
> Ok, I was mistaken. Returning a hash works. It would be helpful if > the ruby exceptions bubbled up to puppet reported the correct line > number from the ruby source -- if that is possible.Could you file a bugreport[1], if there isn''t yet one? Thanks! Then the chances are high that it will get fixed. ~pete [1] http://projects.puppetlabs.com/projects/puppet -- 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.
Rich Rauenzahn
2011-Mar-17 01:34 UTC
Re: [Puppet Users] Re: returning a hash (json object) from custom function?
On Thu, Feb 10, 2011 at 8:35 AM, Peter Meier <peter.meier@immerda.ch> wrote:> Could you file a bugreport[1], if there isn''t yet one? Thanks! > Then the chances are high that it will get fixed.I''d love to, but so far no matter how many times I reset my password, it thinks my login is invalid. Rich -- 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.