我已经成功创建了一个 .rb 自定义事实,它解析一个内置事实以创建一个新值,但是我现在正尝试将它用作Puppet 的嵌套自定义事实。
我要创建的层次结构类似于内置事实,例如运行 Facter(或 Facter -p)将显示:
custom_parent => {
custom_fact_1 => whatever
custom_fact_2 => whatever2
}
木偶清单中的用法是:
$custom_parent.custom_fact_1
到目前为止,我已经尝试过领先的语法,例如:
Facter.add (:custom_parent)=>(custom_fact_1) do
Facter.add (:custom_parent)(:custom_fact_1) do
Facter.add (:custom_parent.custom_fact_1) do
Facter.add (:custom_parent:custom_fact_1) do
Facter.add (custom_parent:custom_fact_1) do
...然而,许多其他变体无法创建嵌套的自定义事实数组。我已经用谷歌搜索了一段时间,如果有人知道是否有可能,我将不胜感激。
我确实发现可以使用 /etc/puppetlabs/facter/facts.d/ 目录中的 .yaml 文件中的数组来创建嵌套事实,如下所示,但是这会设置 FIXED 值并且不会处理我在自定义中需要的逻辑事实。
{
"custom_parent":
{
"custom_fact_1": "whatever",
"custom_fact_2": "whatever2",
}
}
提前致谢。