Ask Your Question
0

hiera lookup not working at module layer

asked 2017-06-11 02:35:03 -0600

rajeevsharma gravatar image

I am not getting why my hiera code is not working though everything seem alright. I am using Puppet 2017.2 and configured hiera 5. I have defined module layer hiera and removed global heira file. Below are my code and issue:

[root@puppetserver fileops]# ls
data  examples  Gemfile  hiera.yaml  manifests  metadata.json  Rakefile  README.md  spec
[root@puppetserver fileops]# cat hiera.yaml
---
version: 5
defaults:
  datadir: data
  data_hash: yaml_data
hierarchy:
  - name: "User details"
    path: "common.yaml"
[root@puppetserver fileops]#

Content of fileops/data/common.yaml

[root@puppetserver fileops]# cat data/common.yaml
---
fileops::myname: rajeev

code of manifest:

class fileops::name (
$myname,
){
notify {"My name is $myname":}
}

I am clueless why I'm getting following error:

Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Class[Fileops::Name]: expects a value for parameter 'myname' on node puppetserver Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run

Let me know if you notice anything I have missed. Otherwise I'll have to use Hiera3.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2017-06-11 03:36:26 -0600

Red Cricket gravatar image

In your data/common.yaml you have:

fileops::myname: rajeev

You probably meant to have:

fileops::name::myname: rajeev
edit flag offensive delete link more

Comments

Strange, I had tried that too but that didn't work. Now it's working. :) Anyway thanks for pointing that out. Now time to play with eyaml.

rajeevsharma gravatar imagerajeevsharma ( 2017-06-11 04:47:42 -0600 )edit
0

answered 2017-06-12 18:18:33 -0600

DevOpsProDude gravatar image

You need to add "data_provider": "hiera", to your metadata.json file in order to enable hiera data in modules

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-06-11 02:35:03 -0600

Seen: 101 times

Last updated: Jun 12