Have you had a look at the functions in puppetlabs-stdlib?
There's a bunch of functions for dealing with hashes and iterating
over them there, keys() for example could be helpful in this case.

On 30 August 2012 07:50, Douglas Garstang <doug.garst...@gmail.com> wrote:
> Boy, am I frustrated. I'm about ready to throw puppet out the window
> here. I'm trying to configure glusterfs, and you know, it kinda made
> sense to separate the data from the manifests, so I went ahead and put
> this into a YAML file, which hiera loads...
>
> glusterfs_volumes:
>   gfsvol01:
>     volume_name: gfsvol01
>     master_node: gfs01.us1.xxx.com         # Make sure only one node
> runs the gluster commands.
>     nodes:
>       - name: gfs01.us1.xxx.com
>         bricks:
>           - device: /dev/bcvg/disk1
>             brick_name: /var/bricks/gfsvol01-0
>           - device: /dev/bcvg/disk2
>             brick_name: /var/bricks/gfsvol01-1
>       - name: gfs02.us1.xxx.com
>         bricks:
>           - device: /dev/bcvg/disk3
>             brick_name: /var/bricks/gfsvol01-0
>           - device: /dev/bcvg/disk4
>             brick_name: /var/bricks/gfsvol01-1
>
> For the last couple of days I have been dealing with the inadequacies
> of puppet in dealing with working with this kind of data structure.
> You can't easily iterate through it, and every time you do, you have
> to write a new definition that takes an array. The whole thing ends up
> turning into a giant complicated mess.
>
> I tried writing some custom functions in ruby that do things like,
> return a list of nodes for a volume, or return a list of bricks for a
> node, but it really irks me that I have to keep writing ruby scripts
> for this (since ruby makes my eyes bleed).
>
> So... what are my options here? Aren't we supposed to strive for
> separating the manifest from the data? I could probably get away with
> a few definitions that take a set of parameters. However, when the
> time comes to say, add a new node to the cluster, we have to modify
> the manifest. At one point, I had this working so that all you had to
> do was add a node to the yaml file, make ZERO changes to the manifest
> file, and after running puppet, it would add the node to the cluster.
>
> It may make my life easier if I flatten the yaml file, but then I'm
> changing the data to suit the limitations of the DSL.
>
> At this point, I'm very close to simply sticking with the yaml file,
> have puppet push that out to the clients, write some python scripts to
> do all the magic (reading the yaml file), and have puppet run those
> scripts with Exec {}.
>
> Is proper array/hash iteration ever going to be added to puppet?
>
> Doug.
>
> --
> 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.
>



-- 
Erik Dalén

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