Ask Your Question

module data hiera: Function lookup() did not find a value for the name

asked 2017-03-23 05:47:16 -0600

rssh22 gravatar image

updated 2017-03-23 06:35:22 -0600

Given a module like:

|-- data
|   `-- data.yaml
|-- hiera.yaml
|-- manifests
|   `-- init.pp
`-- metadata.json

version: 4
datadir: data
#data_hash: yaml_data
  - name: "data"
    backend: yaml
    path: "data/data.yaml"
  - name: "common"
    backend: yaml
    class mymodule {
      $var = lookup('mymodule::var')
      notify {"var: ${var}":}
    mymodule::var: 'var value from mymodule/data/data.yaml'
      "name": "example-mymodule",
      "version": "0.0.1",
      "author": "Pat",
      "license": "Apache-2.0",
      "summary": "A module for a thing",
      "source": "",
      "project_page": "",
      "issues_url": "",
      "tags": ["things", "stuff"],
      "operatingsystem_support": [
        "operatingsystemrelease":[ "5.0", "6.0" ]
        "operatingsystem": "Ubuntu",
        "operatingsystemrelease": [ "12.04", "10.04" ]
      "dependencies": [
        { "name": "puppetlabs/stdlib", "version_requirement": ">= 3.2.0 < 5.0.0" }
      "data_provider": "hiera"

root@puppet-pil00:/etc/puppetlabs#  /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 'mymodule::var' on node
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

why lookup() can't find mymodule::var variable in data.yaml?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-03-24 13:44:02 -0600

Red Cricket gravatar image

updated 2017-03-24 22:45:39 -0600

According the the puppet style guide :

You should avoid using calls to Hiera functions in modules meant for public consumption, because not all users have implemented Hiera. Instead, we recommend using parameters that can be overridden with Hiera.

You can avoid calling lookup() by making var a class parameter. So you puppet class would look like this:

class mymodule (
) {
      notify {"var: ${var}":}

Also I am not sure your hiera.yaml is correct. Have you tried just using the default hiera.yaml a just adding the line for your data yaml file? You should double check you hiera set up by running hiera from the command line on your puppet master with debug. Something like.

hiera --debug var environment=production

And see if the yaml files you assume are being searched are actually being read.

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


Asked: 2017-03-23 05:47:16 -0600

Seen: 4,366 times

Last updated: Mar 24 '17