我对puppet
很新。我配置了hiera
文件,其路径为/etc/puppetlabs/puppet/hiera.yaml
,因此
version: 5
hierarchy: []
backends:
- yaml
yaml:
- datadir: /etc/puppetlabs/puppet/some_dir
我收到此错误
Warning: The function 'hiera' is deprecated in favor of using 'lookup'. See https://docs.puppet.com/puppet/5.3/reference/deprecated_language.html
(file & line not available)
Error: Evaluation Error: Error while evaluating a Function Call, Lookup of key 'user_dir' failed: The Lookup Configuration at '/etc/puppetlabs/puppet/hiera.yaml' has wrong type, unrecognized key 'backends'
The Lookup Configuration at '/etc/puppetlabs/puppet/hiera.yaml' has wrong type, unrecognized key 'yaml' at /etc/puppetlabs/code/environments/production/manifests/site.pp:30:17 on node puppet,some_cluster_DNS.internal
最初,我为密钥:backends:
:yaml:
提供了这种格式,但它似乎不是5
版本的常规格式,因此我删除了{{1}签名
有人有想法吗?
答案 0 :(得分:2)
首先,就该警告而言,如果您使用的是Hiera> = https://puppet.com/docs/puppet/4.10/hiera_use_function.html,则必须从Hiera lookup
函数切换到Puppet hiera
函数。 / p>
其次,就该错误而言,我会参考有关如何设置Hiera 5配置文件的文档:https://puppet.com/docs/puppet/4.10/hiera_config_yaml_5.html
使用正确的格式,您的配置文件将如下所示:
# /etc/puppetlabs/puppet/hiera.yaml
version: 5
defaults:
- data_hash: yaml_data
- datadir: /etc/puppetlabs/puppet/some_dir
hierarchy: []
在Hiera 5中不允许在最后一行(为datadir
后端指定特定的yaml_data
)尝试执行的操作。如果要为datadir
指定datadir
一个特定的后端,那么你需要为该后端指定层次结构的级别(或者只是后端的datadir;你可以用它来自定义几个矩阵的深度)并在那里指定hierarchy:
- name: yaml data
data_hash: yaml_data
datadir: /etc/puppetlabs/puppet/some_dir
paths:
- "%{trusted.certname}.yaml"
- common.yaml
。例如:
package main
import (
"fmt"
"encoding/json"
)
type b struct {
Name string `json:"name"`
Description string
Url string
}
type a struct {
*b
MimeType string `json:"mimeType"`
}
func main() {
bc := b{"test", "testdecription", "testurl"}
ac := a{nil, "jpg"}
ac.b = &bc
js, _ := json.Marshal(ac)
fmt.Println(string(js) )
}