我正在将节点inheritance树移至hiera。 目前正在研究层次结构 。 在hiera之前,我的节点有这样一个层次结构
base pre-prod qa nodes staging nodes development nodes prod nodes
现在我正在尝试与hiera获得相同的层次。 开始我有这个
:hierarchy: - base - "%{environment}" - "%{clientcert}"
但是我需要另一个级别来捕捉预先刺激和刺激 。 我的想法是添加一个入口puppet.conf ,类似
[agent] realm = pre-prod
然后
:hierarchy: - base - "%{realm}" - "%{environment}" - "%{clientcert}"
几个问题
你可以在客户端做到这一点,而不是一个puppet.conf设置的自定义事实。 但是,我会说在服务器端,在Hiera的数据。 我用于类似的技巧如下:
在每个服务器的clientcert级别设置clientcert数据。 在你的情况下:
realm: "pre-prod"
在site.pp之前,通过hiera_include中的site.pp将该variablessite.pp全局范围中:
$realm = hiera(realm) hiera_include(classes)
该variables已从clientcert.yaml文件中获取,现在将用于根据您的层次结构中的"%{realm}"configuration从pre-prod.yaml提取的clientcert.yaml中的查找。