gpt4 book ai didi

puppet - 复杂的 hiera 查找不起作用

转载 作者:行者123 更新时间:2023-12-04 17:09:13 47 4
gpt4 key购买 nike

我在 yaml 文件中有以下定义:

keepalived:
cluster_name: "cluster.example.lan"
cluster_ip: "192.168.1.10"
cluster_nic: "eth0"
haproxy:
bind_address: %{hiera('keepalived::cluster_ip')}

结果是 bind_address我有一个空字符串。

如果我使用 %{hiera('keepalived')}我已经打印了整个哈希,但我只需要 cluster_ip从这个哈希。我如何查找 cluster_ip ?

最佳答案

我觉得不是possible:

Hiera can only interpolate variables whose values are strings. (Numbers from Puppet are also passed as strings and can be used safely.) You cannot interpolate variables whose values are booleans, numbers not from Puppet, arrays, hashes, resource references, or an explicit undef value.

Additionally, Hiera cannot interpolate an individual element of any array or hash, even if that element’s value is a string.


您始终可以将 cluster_ip 定义为变量:
common::cluster_ip: "192.168.1.10"
然后使用它:
keepalived:
cluster_name: "cluster.example.lan"
cluster_ip: "%{hiera('common::cluster_ip')}"
cluster_nic: "eth0"

haproxy:
bind_address: "%{hiera('common::cluster_ip')}"

关于puppet - 复杂的 hiera 查找不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27860333/

47 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com