Hiera 3 Puppet 4.2 can't manage empty value in yaml datasource ?

asked 2015-08-16 18:41:49 -0500

lukeskywalker gravatar image

updated 2015-08-17 09:21:00 -0500

I'm facing some issues to use Hiera 3 with Puppet 4.2. When applying my puppet manifest using this command:

puppet apply environments/production/manifests/init.pp --hiera_config=hiera.yaml

I get the following error:

Error: Evaluation Error: Error while evaluating a Function Call, Could not find data item myclass::ensure in any Hiera data file and no default supplied at /home/vagrant/temp/environments/production/manifests/init.pp:13:39 on node a

Here is the directory structure :

$ tree
.
├── environments
│   └── production
│       ├── config.yaml
│       └── manifests
│           └── init.pp
└── hiera.yaml

content of config.yaml:

$ cat hiera.yaml 
---
:backends:
  - yaml

:hierarchy:
  - config

:yaml:
  :datadir: environments/production

content of init.pp:

class myclass(
  $version                          = $myclass::params::version,
  $ensure                           = $myclass::params::ensure,
) inherits myclass::params {

  notify {"$version": }
  notify {"$ensure": }

}

class myclass::params {
  $version                          = hiera('myclass::version', '1.0.0')
  $ensure                           = hiera('myclass::ensure', 'running')
}

class {'myclass': }

content of hiera data source:

$ cat config.yaml
---
myclass::version: '1.0.0'
myclass::ensure:

Looks like Hiera can't handle empty values from a yaml data source and/or replace them by default value?

edit retag flag offensive close merge delete

Comments

Maybe I'm missing something, but what's the point of defining myclass::ensure: with no data? I'd call this a usage problem.

ramindk gravatar imageramindk ( 2015-08-21 15:52:12 -0500 )edit

You shouldn't need to define it if you don't need non-default behavior, but doesn't `myclass::ensure: ~` work? (see also: http://ask.puppetlabs.com/question/19711/yaml-for-puppet-users/ => "Using the NULL/tilde in your YAML")

Rikken gravatar imageRikken ( 2015-10-18 16:10:36 -0500 )edit