Thanks for everyone's help. I figured out what the issue was over the weekend. It appears that when the ruby script is run in a puppet run, puppet loads the yaml dictionaries specific to puppet. However, when I was testing the script in ruby I was not loading the yaml dictionaries for puppet. This was causing my script to get a generic loaded yaml of #<YAML::Object:0x2ada01f7cf00> instead of the correctly loaded yaml #<Puppet::FileServing::Metadata:0x2ac7987b9c08>. When the dictionaries are loaded for puppet it no longer has an "ivars" hash with content or metadata. I just needed to do "YAML.load(apitruthtag("content")).content" instead of "YAML.load(apitruthtag("content")).ivars["content"].
However, because I am still not loading the dictionary outside of the puppet run my script will not function correctly if just executed in ruby. Does anybody know how to properly load the puppet yaml dictionary outside of a puppet run? FYI: The raw yaml data from puppet is: --- !ruby/object:Puppet::FileServing::Content content: | --- role: - base env: - dev expiration: 2011-07-11 18:57:08.413941 +00:00 links: :manage path: /etc/puppet/modules/truth/files/private/domain.inter/server01/ truth_tags.yml stat_method: :lstat -- Derek On Jul 9, 3:03 pm, Ken Barber <k...@puppetlabs.com> wrote: > So ... > > > servermd5 = YAML.load(apitruthtag("metadata")).ivars["checksum"] # > > When executed from a puppet run I tells me that ivars is undefined. > > What does the output of apitruthtag("metadata") show you between each > run in facter, irb and puppet? Can you output each to a file and > analyze the difference? > > > irb, ruby, or facter: > > yaml parsed http response = #<YAML::Object:0x2ada01f7cf00> > > > puppet run: > > yaml parsed http response = #<Puppet::FileServing::Metadata: > > 0x2ac7987b9c08> > > with error: > > > undefined method `ivars' for #<Puppet::FileServing::Metadata: > > 0x2ac7987152c0> > > #<NoMethodError: undefined method `ivars' for > > #<Puppet::FileServing::Metadata:0x2ac7987152c0>> > > So when you run it with all the Puppet libraries the YAML object is > being serialized back into a Ruby object Puppet::FileServing::Metadata > ... I'm really curious what the raw YAML output looks like. This > should only happen I think if the YAML output has meta information > that matches that class type for example: > > --- > !ruby/object:Puppet::FileServing::Metadata {} > > I get the feeling the YAML you are getting back isn't what you were > expecting and looking at the contents of the raw output might give a > better clue as to why. > > ken. > > -- > "Join us for PuppetConf, September 22nd and 23rd in Portland, > OR:http://bit.ly/puppetconfsig" -- 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.