Data lookup() via redis hiera-backend fails on puppet 5

asked 2017-10-26 12:27:56 -0600

Hi all,

I am investigating a possible move from puppet open source 3.8.x to puppet 5 and I was trying out the new application and services. I solved almost all the problems until I hit a problem with hiera and the redis backends.

https://github.com/reliantsolutions/h...

NOTE: "I know is old and from 2015" but trust me, basically all hiera backend (mongo, mysql, etc) are old or don't work.

So, with the redis backend activated and the following settings:

defaults:
  datadir: hieradata
  data_hash: yaml_data
hierarchy:
  - name: redis
    hiera3_backend: redis
    paths:
      - "%{environment}"
    options:
      host: x.x.x.x
      soft_connection_failure: true

I am able to resolve the key on the puppet master with puppet lookup:

# puppet lookup 'app::params::git_repo_tag' --node node-c9cfeeac --environment production --render-as s
pro

For more information:

# puppet lookup 'app::params::git_repo_tag' --node node-c9cfeeac --environment production --trace --explain
Searching for "lookup_options"
  Global Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Hierarchy entry "redis"
      Path "/etc/puppetlabs/puppet/hieradata/production"
        Original path: "%{environment}"
  Module "app" not found
Searching for "app::params::git_repo_tag"
  Global Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Hierarchy entry "redis"
      Path "/etc/puppetlabs/puppet/hieradata/production"
        Original path: "%{environment}"
        Found key: "app::params::git_repo_tag" value: "pro"

NOTE: I tried to fix the lookup lookup_options, but adding data on redis didn't work out. I don't know if and in which way they may be connected.

It works also with compile. Now, even if that working, when I actually apply the client on a test node I have the following error:

# /opt/puppetlabs/bin/puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Function lookup() did not find a value for the name 'app::params::git_repo_tag' on node node-c9cfeeac
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

In my puppet code I refer to the var like this:

repo_reference_to_pull => lookup('app::params::git_repo_tag'),

NOTE: Before I was using hiera(), but that too was failing so I decided to update the code.

I tried various combination of the hiera call:

[...]
repo_reference_to_pull => lookup( { 'name'  => 'app::params::git_repo_tag','merge' => {'strategy' => 'first',},}),
[...]

But with no success. Like I said, the variable CAN be resolved on the puppetmaster, but not from the client.

However, also the following call fails (with --explain-options):

# puppet lookup 'app::params::git_repo_tag' --node node-c9cfeeac --environment production --explain-options --trace
Merge strategy hash
  Global Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Hierarchy entry "redis"
      Path "/etc/puppetlabs/puppet/hieradata/production"
        Original path: "%{environment}"
  Module "app" not found

I cannot understand what is failing in the agent call. Anyone can help shed some light on this problem?

NOTE: I tried to move to the mongo backend but is too old. The mysql one fails during mysql gem compilatin for a ruby ... (more)

edit retag flag offensive close merge delete