Hiera 3 + Puppet 4.2 can't manage empty value

2019-08-21 16:38发布

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?

标签: puppet hiera
0条回答
登录 后发表回答