On Mon, Jul 11, 2011 at 4:17 PM, Derek Tamsen <dtam...@gmail.com> wrote:

> Thanks. Unfortunately, it seems I will need to wait until we upgrade
> puppet as version 0.25.4 does not seem to have 'puppet/util/zaml'.
>

Then I'm more confused :)

does

require 'puppet'
require 'yaml'

just do the right thing? If not, I'd post to the puppet-dev list and see if
the more developer-focused crowd can give you a better answer for 0.25.4.







>
> --
> Derek
>
> On Jul 11, 2:56 pm, Nigel Kersten <ni...@puppetlabs.com> wrote:
> > On Mon, Jul 11, 2011 at 11:36 AM, Derek <dtam...@gmail.com> wrote:
> > > 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?
> >
> > You should be able to load it as
> >
> > require 'puppet/util/zaml'
> >
> > and use ZAML instead of YAML.  That's the version of YAML we're vendoring
> to
> > fix a whole list of bugs we ran into.
> >
> > There's more complication going on in:
> >
> > lib/puppet/util/monkey_patches.rb
> >
> > showing how we monkey patch the various yaml methods on objects to
> actually
> > talk ZAML instead.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > 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.
> >
> > --
> > Nigel Kersten
> > Product Manager, Puppet Labs
> > Twitter: @nigelkersten
> >
> > *Join us for **PuppetConf *<http://www.bit.ly/puppetconfsig>
> > September 22nd and 23rd in Portland, Oregon, USA.
> > *
> > *
>
> --
> 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.
>
>


-- 
Nigel Kersten
Product Manager, Puppet Labs
Twitter: @nigelkersten

*Join us for **PuppetConf *<http://www.bit.ly/puppetconfsig>
September 22nd and 23rd in Portland, Oregon, USA.
*
*

-- 
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.

Reply via email to