0

我在将 Hiera 3 与 Puppet 4.2 一起使用时遇到了一些问题。使用此命令应用我的木偶清单时:

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

我收到以下错误:

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

这是目录结构:

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

config.yaml 的内容:

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

:hierarchy:
  - config

:yaml:
  :datadir: environments/production

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': }

hiera数据源内容:

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

看起来 Hiera 无法处理来自 yaml 数据源的空值和/或用默认值替换它们?

4

0 回答 0