我试图在define中传递多个参数.
以下是我的代码.我想在define中传递两个数组,但是我只能传递一个如下所示.
class test {
$path = [$path1,$path2]
$filename = [$name1,$name2]
define testscript { $filename: } // Can able to pass one value.
}
define testscript () {
file {"/etc/init.d/${title}": //Can able to receive the file name.
ensure => file,
content => template('test/test.conf.erb'),
}
Run Code Online (Sandbox Code Playgroud)
从我上面的代码,我可以检索filename定义资源内部.我还需要path在模板中设置值.我无法在模板中发送/检索第二个参数.
有没有办法改进我的代码以传递定义资源中的两个值($path和$filename)?
任何帮助深表感谢.
我在yaml文件中有以下定义:
keepalived:
cluster_name: "cluster.example.lan"
cluster_ip: "192.168.1.10"
cluster_nic: "eth0"
haproxy:
bind_address: %{hiera('keepalived::cluster_ip')}
Run Code Online (Sandbox Code Playgroud)
结果bind_address我得到一个空字符串.
如果我使用%{hiera('keepalived')}我已经打印了整个哈希,但我只需cluster_ip要从这个哈希.我该如何查找cluster_ip?