Hiera 3 + Puppet 4.2无法管理yaml数据源中的空值

时间:2015-08-16 23:38:33

标签: puppet hiera

我在使用Hiera 3和Puppet 4.2时遇到了一些问题。 使用此命令应用我的puppet清单时:

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数据源中的空值和/或将其替换为默认值?

0 个答案:

没有答案