torrancew / hiera-foreman

A hiera backend that queries the Foreman for data
34 stars 15 forks source link

Support array syntax #6

Open mchugh19 opened 12 years ago

mchugh19 commented 12 years ago

While foreman does not directly support arrays as parameters, maybe it could be supported in the hirea lookup.

Creating a variable such as sshd_listen_address and assigning it the value [ '0.0.0.0', '::', '127.0.0.1' ] currently results in an error: Error 400 on SERVER: can't convert Array into Hash at /etc/puppet/modules/development/sshd/manifests/init.pp:3 on node cas-interv-clnt.cas.unt.edu

Where the line it errors out on is: $sshd_listen_address = hiera_array("sshd_listen_address", [ '0.0.0.0', '::' ])

Furthermore, as expected, the hiera command line does not see the foreman line as an array. hiera -a -c /etc/puppet/hiera.yaml -m cas-interv-clnt.cas.unt.edu sshd_listen_address ["[ '0.0.0.0', '::', '127.0.0.1' ]"] hiera -c /etc/puppet/hiera.yaml -m cas-interv-clnt.cas.unt.edu sshd_listen_address [ '0.0.0.0', '::', '127.0.0.1' ]

So perhaps when hiera-foreman sees a '[', it could interpret the contents as an array.

mchugh19 commented 12 years ago

I guess this basically involves supporting the hash and array resolution types like in https://github.com/crayfishx/hiera-gpg/blob/master/lib/hiera/backend/gpg_backend.rb

torrancew commented 12 years ago

Yep. I think this shouldn't be too bad to support, but first I'd like to merge smartvar_queries branch, if you think that's a good way to move forward (I'm basically trying to make the Foreman backend present its data in a structure more similar to the other backends).