我正在使用以下木偶类
class myclass{
$foo = [{"id" => "bar", "ip" => "1.1.1.1"}, {"id" => "baz", "ip" => "2.2.2.2"}]
map {$foo:}
define map () { notify {$name['id']: } }
}
但是这给了我
err: Could not retrieve catalog from remote server: Could not intern from pson: Could not convert from pson: Could not find relationship target "Change_config::Map[ip1.1.1.1idbar]"
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run
这是什么原因?
此致 Malintha Adikari
答案 0 :(得分:2)
您的数组包含哈希值。资源声明语法仅适用于字符串数组。
$foo = ["bar", "baz"]
map {$foo:}
define map () { notify {$name: } }
如果要传递每个资源标题的数据,则需要
create_resources
函数未经测试的示例代码:
$foo = {
"bar" => { "ip" => "1.1.1.1" },
"baz" => { "ip" => "2.2.2.2" },
}
create_resources('map', $foo)
define map ($ip="") { notify { "$name has ip $ip": } }