是否有一种方法可以使用在某些清单中定义的变量?
我是这样尝试的:
manifest.pp
if $::ipaddress_bond0 {
$primary_interface = 'bond0'
notify{"$primary_interface":}
}
else {
$primary_interface = 'eth0'
notify{"$primary_interface":}
}
hiera.yaml
some_config:
server:
foo:
bar: "%{::primary_interface}"
这是可能的。请看下面的例子:
test.pp
class nodes::test
{
$value1 = 'abc'
$value2 = hiera('test::value2')
$value3 = hiera('test::value3')
notify{ " v1 ${value1}": }
notify{ " v2 ${value2}": }
notify{ " v3 ${value3}": }
}
include nodes::test
test.yaml
test::value2: "%{value1}"
test::value3: "%{value4}"
运行测试:
puppet apply test.pp
通知:v1 abc
注意事项:v2 abc
注意:v3
请记住,在hiera中使用傀儡变量是一个非常糟糕的做法。