[Puppet Users] Ruby, YAML & Hiera data

Matthew Burgess
Tue, 22 Jul 2014 15:20:15 -0000

Hi,

It's probably best for you to not ask why we're doing the following,
but here's what we're trying to achieve:

We'd like to programmatically edit our Hiera data, and we're using the
YAML backend.  I can successfully load the correct YAML file and make
the changes we require.  However, we've hit upon a bit of a stumbling
block if the YAML file contains an interpolation token, if gets
'corrupted' by the default Ruby YAML emitter like so:

ipaddress: "%{::ipaddress_eth0}"

becomes

ipaddress: ! '%{::ipaddress_eth0}'

When I inspect the data following the load of the YAML file, I can see
it's been loaded correctly, so it seems to be when I call YAML.dump()
that it gets 'corrupted'.

Just posting here to see if anyone else has done anything similar and
overcome the same problem; my google-fu led me down the path of some
custom Psych emitters, but the gist I re-used
(https://gist.github.com/mislav/2023978) exhibited the same issue.

The frustration here is that the data we need to change are guaranteed
to *not* have any interpolation tokens, but I can't see a way to
overwrite just the portion of the file that I've changed, hence why
I'm dumping out the full file again and hitting this issue.

Cheers,

Matt.

--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/CAKUTv3%2BUboAb_gL7bkq-3yeWnsdv75hMqhoe2yGo99ZMOzXsDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.