On 01/12/2014 09:15 AM, CD wrote:
> 1. hiera($variable) returns a hash but for resource to iterate it
> requires and array. Any idea how to convert it to an array
Hiera returns whatever it reads from your data file. If your json
deserialized to an array, that is what Hiera will return to you.
> 2. How to specify ip so that it get the corresponding value from eth0 or
> eth1.
You might want to hand the whole respective data structure into your
define (all code untested):
$nic_list = keys($nics)
network_config { $nic_list: data => $nics }
define network_config($data) {
$ip = $data[$name]["ip"]
...
[ your implementation here ]
}
Depending on where else you need this specific data, you may
alternatively tailor it in a way that will enable you to just
create_resources("network_config", $nics)
As an aside, this design looks rather cumbersome and limiting you. I
found that hiera is most powerful and intuitive if it can itself figure
out which dataset to return (e.g. <hostname>.json) and splitting things
out into many keys.
Of course, it's not a one-size-fits-all issue, if your mileage is better
this way, feel free to stick to it, of course.
HTH,
Felix
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/52D57A69.5030508%40alumni.tu-berlin.de.
For more options, visit https://groups.google.com/groups/opt_out.