Hiera Interpolation of data

16 views
Skip to first unread message

Gino Lisignoli

unread,
Mar 19, 2018, 11:19:36 PM3/19/18
to Puppet Users
Hello

I'm using hiera with the http backend (as couchdb) which works for data lookup, but I want to user data interpolation (https://puppet.com/docs/puppet/5.0/hiera_interpolation.html).

At the moment I am trying to do a simple test of:

class foo (
  $bar
= lookup("some::path::var")
) {
  notify
{ 'bar':
    message
=> $bar
 
}
}

Couchdb:
{
 
"some::path::var": "%{::fqdn}"
}


But my notify output is always:

Notice: /Stage[main]/Foo::Notify[bar]/message:current_value absent, should be %{::fqdn} (noop)

Any ideas why this isn't getting resolved as the fqdn fact?

Henrik Lindberg

unread,
Mar 20, 2018, 7:59:55 AM3/20/18
to puppet...@googlegroups.com
On 20/03/18 04:19, Gino Lisignoli wrote:
> Hello
>
> I'm using hiera with the http backend (as couchdb) which works for data
> lookup, but I want to user data interpolation
> (https://puppet.com/docs/puppet/5.0/hiera_interpolation.html).
>
> At the moment I am trying to do a simple test of:
>
> |
> classfoo (
>   $bar =lookup("some::path::var")
> ){
>   notify {'bar':
>     message =>$bar
> }
> }
> |
>
> Couchdb:
> |
> {
> "some::path::var":"%{::fqdn}"
> }
> |
>
>
> But my notify output is always:
>
> Notice: /Stage[main]/Foo::Notify[bar]/message:current_value absent,
> should be %{::fqdn} (noop)
>
> Any ideas why this isn't getting resolved as the fqdn fact?

Afaik, the interpolation should be performed by the backend itself for
hiera 3 backends. Does other interpolations work with the couchdb
backend? If not, log a ticket for that backend.

The right path forward is to use hiera 5 and write a hiera 5 backend for
couchdb. This is as simple as writing a function - probably of the
"lookup_key" kind. When doing such a lookup, there is a method to call
on the "lookup context" object given to the function that performs
interpolation.

Others that have written hiera 5 backend functions have done so quite
easily and made the hiera 3 backend be capable of supporting both the
hiera 3 backend API and the new hiera 5 at the same time.

Best,
- henrik


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

Reply all
Reply to author
Forward
0 new messages