我有这样的哈希
net:ip { '': ip => { ip1 => { addr => '192.168.10.1', device => 'eth0', }, ip2 => { addr => '192.168.50.10', device => 'eth10', }, } }
在我的清单中,我这样称呼
define net::ip ( $ip={}, ) { ... }
我的问题是我如何引用哈希迭代的当前循环。 我希望能够使用这个清单中的“开发”字段,但由于散列有IP1,IP2我不知道它的数字?
谢谢丹
以下示例可能有所帮助 分别创build散列并通过定义types访问它。
$foo = [{"addr" => "bar", "port" => "1"}, {"addr" => "bat", "port" => "2"}] testmod::bar {$foo:} define testmod::bar () { $var1 = $name["addr"] $var2 = $name["port"] notify {"${var1}_${var2}": } }