哈希语法不工作在木偶清单

我现在终于可以了,有人可以帮我理解我在做什么错在这里:

我的nodes.pp(这个文件除了这个定义之外没有别的东西)

node test { net::addr { 'routing': routes = { route1 => { address => '192.168.23.14', netmask => '255.255.255.0', gateway => '192.168.23.1', dev => 'eth0', }, route2 => { address => '192.168.1.3', netmask => '255.255.255.0', gateway => '192.168.1.1', dev => 'eth2', }, } } } 

不pipe我改变什么,我一直在testing服务器上每次运行都会得到这个结果,运行就立即终止:

err:无法从远程服务器检索目录:SERVER上的错误400:无法parsing环境生成:“=”处出现语法错误; 在节点testing的/etc/puppet/manifests/nodes/nodes.pp:3处预期'}'

在第三行,这是我从上面得到的:

net :: addr {'routing':

我在这里错过了什么? 请帮助,因为它驱使我绝望!

谢谢丹

从我坐的地方来看,第三行是:

 routes = { 

你需要在这里的右尖括号。

如前所述,您需要将“=”更改为“=>”资源运算符。

这个命令在debugging时会有帮助:

 puppet parser validate test.pp 

这将帮助你find你的语法错误。

您需要一个=>运算符来定义一个资源参数:

 net::addr { 'routing': routes => { ... 

以这种方式指定参数有点混乱,难以阅读。 我build议先将这个复杂的散列保存在一个variables中:

 $route_hash = { route1 => { address => '192.168.23.14', netmask => '255.255.255.0', gateway => '192.168.23.1', dev => 'eth0', }, route2 => { address => '192.168.1.3', netmask => '255.255.255.0', gateway => '192.168.1.1', dev => 'eth2', }, } net::addr { 'routing': routes => $route_hash, }