我有一个简单的 puppet 定义资源,如下所示:
define mything($number, $device, $otherthing) {
file{"/place/${number}":
ensure => directory
}
mount { "/place/${number}":
device => $device,
ensure => mounted,
require => File["/place/${number}"]
}
file {"/place/${number}/${otherthing}":
ensure => directory,
require => Mount['/place/${number}']
}
}
我需要使用不同的参数多次调用此资源,但如果不明确重复调用,我无法弄清楚如何执行此操作mything()
。
理想情况下,我会将所有参数存储在某种数组中,然后调用mything($array)
,有点像这样:
$array = [
{number => 3, something => 'yes', otherthing => 'whatever'},
{number => 17, something => 'ooo', otherthing => 'text'},
{number => 4, something => 'no', otherthing => 'random'},
]
mything($array)
但这似乎不起作用。我很确定如果我的资源只接受一个参数并且我只有一个平面数组值,这会起作用,但是我可以用多个命名参数做同样的事情吗?