Trying to get complex data set into Puppet from ENC

45 views
Skip to first unread message

Jared Ballou

unread,
May 22, 2012, 8:10:21 PM5/22/12
to Puppet Users
Hi everyone,

I've been reading the groups here for a while, and have gotten a lot
of things fixed by finding other people's posts, so hopefully someone
will be able to set me straight. I am working on a Puppet deployment
that needs to have a lot of disparate data pulled together, and as far
as the ENC I created to pull it all in, everything has worked great.
However, I'm running into a problem instantiating Apache virtual
hosts. Here is some abridged output from my ENC:
---
classes:
app::lamp:
appdata:
sites:
Some Website:
id: "2"
name: Some Website
servername: somewebsite.com
svntag_prod: trunk
svntag_dev: trunk
documentroot: ~
Another Website:
id: "4"
name: Another Website
servername: anotherwebsite.com
svntag_prod: "1.2.0"
svntag_dev: "1.3.0-rc4"
documentroot: ~
Third Website:
id: "6"
name: Third Website
servername: thirdwebsite.com
svntag_prod: trunk
svntag_dev: trunk
documentroot: "/opt/thirdwebsite/customhtdocs"

So, I have some other classes that are parameterized and I can
reference $appdata[$key] inside those manifests and everything works
fine for strings or arrays. My issue is getting this hash of hashes in
[appdata][sites] turned into vhosts. I tried using create_resources to
no avail, tried dumping the ENC to YAML and using Hiera to parse that,
and I have struck out in every way. And, honestly, I think there must
be a better way to do this. The data is all in a single MySQL table,
so I looked at hiera-mysql backend, but I think I am over my head
here. Has anyone got a good example I could reference doing something
like this, especially for multi-dimensional hashes? I was starting to
look at just converting it to JSON or just comma delimited text and
feed it to Puppet as a string to be parsed, but that just seems wrong.
I've been at this 4 hours now with no luck, any help anyone can
provide would be greatly appreciated.

Thanks,

-Jared

Danie van Zyl

unread,
Dec 20, 2012, 4:40:03 AM12/20/12
to puppet...@googlegroups.com
I'm having the same problem.

Luke Bigum

unread,
Dec 20, 2012, 4:46:42 AM12/20/12
to puppet...@googlegroups.com
Hi Jared,
I use create_resources() a bit with hash data pulled from Hiera and don't have too many problems with it (despite it's annoyingly vague error messages). Do you have an example of where it has not worked for you? I would have thought:

create_resources('apache::vhost', $appdata[$key][$sites])

should work fine, though I don't have an ENC so I'm not sure exactly how this data gets presented to you - it is a Puppet hash, right?
Reply all
Reply to author
Forward
0 new messages