Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do I access merged hiera data directly from a template?

I have hiera data that is being merged in via 3 different levels:

   - name/hostname
   - class/hostclass
   - global

and when I use a hiera_hash to extract the merged data in my module, it works fine:

$module_vars = hiera_hash('module_data', undef)

Unfortunately, I can't pass $module_vars directly to the template, because it's being called from a different module But, when I try to access the data directly from the erb template like so:

<% $module_vars = scope.function_hiera(['module_data']) -%>

I only get the first hiera set that it finds. I don't get the merged hiera data.

Is there a way I can make the template access the hiera data in the same way that hiera_hash does?