Ask Your Question
0

Hiera custom backend not working

asked 2017-09-12 07:55:49 -0600

flobob gravatar image

updated 2017-10-10 15:20:12 -0600

ramindk gravatar image

Hey,

I'm trying to write a custom hiera backend for mongodb with PE2017-2. I found some working examples with hiera v3 but I'd like to use hiera v5.

So I've just wrote a kind of "hello world" for my 'lookup_key' backend function, in vain...

Here is my hiera configuration:

/etc/puppetlabs/puppet/hiera.yaml

---
version: 5
hierarchy:
  - name: "common data (MongoDB version)"
    lookup_key: mongodb
    paths: 
      - "node/%{trusted.certname}" 
      - "common"
    options:
      dbname: "hiera"
      collection: "config"
      host: "localhost"

Here is my custom lookup_key backend:

environments/production/modules/mongo/lib/puppet/functions/mongodb.rb

Puppet::Functions.create_function(:mongodb) do 
  Puppet.warning("mongodb") 
  dispatch :mongodb do 
    param 'String[1]', :key 
    param 'Hash[String[1],Any]', :options 
    param 'Puppet::LookupContext', :context 
  end

  def mongodb(key, options, context) 
    Puppet.warning("Custom_lookup_key_mongodb_backend") 
    context.not_found 
    {} 
  end 
end

I used the 'lookup' function to solicit hiera and its custom backend but it does not appear to be called. Indeed, I have no "WARN" entries in 'puppetserver.log' despite 'Puppet.warning' calls...

I do not understand what I missed.

Thank you

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-10-12 15:07:18 -0600

eric aldinger gravatar image

You may want to look at hiera provider for mssql.

https://github.com/LMacchi/hiera_mssql

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-09-12 07:55:49 -0600

Seen: 758 times

Last updated: Oct 12