passing array param to hiera

454 views
Skip to first unread message

mickael avedissian

unread,
Nov 23, 2012, 12:19:11 PM11/23/12
to puppet...@googlegroups.com
Hi,

I'm having an issue trying to pass an array parameter for a hiera lookup

hiera.yaml:
:hierarchy:
  - some_place/%{hostnames}

dummy_host.yaml:
---
host: 'dummy_host'
instances:
  dummy01:1.2.3.4
  dummy02:1.2.3.4
  dummy03:1.2.3.4


in my manifest I have:
$hostnames = [ 'dummy_host', 'dummy_host1' ]
$hiera_lookup = hiera('instances')


The above results in me getting the following error:
can't convert Array into String at manifest.pp:18 on node hostname


I also tried using hiera_array and hiera_hash without success.

Thank you for your help
Mike

mickael avedissian

unread,
Nov 23, 2012, 12:27:42 PM11/23/12
to puppet...@googlegroups.com
FYI, 

if I replace $hostnames = [ 'dummy_host', 'dummy_host1' ]  by $hostnames = 'dummy_host'
this works.

frap

unread,
Nov 25, 2012, 10:34:50 PM11/25/12
to puppet...@googlegroups.com
I think you need to user "hiera_array" rather than hiera_lookup

jcbollinger

unread,
Nov 26, 2012, 10:29:21 AM11/26/12
to puppet...@googlegroups.com


Hiera does not provide the feature you are looking for.  Each element of the hierarchy array in hiera.yaml identifies one data source.  You cannot expand a single element into multiple elements by interpolating an array.

I think you are heading in the wrong direction by attempting to manipulate your data hierarchy.  Play all the games you want with your data, but approach your hierarchy with great care.

In this particular case, it appears that you want to perform a UNION query of some of your hiera data.  I can't think of a good way to do that in core Puppet, but it should be straightforward to write a custom function for it.


John

Reply all
Reply to author
Forward
0 new messages