0

我在厨师模板中有以下代码,但在上传到厨师服务器时出错。我该如何解决?

<%
    contents_hash = File.read('/tmp/cluster_hash')
        neoservers_hash  = JSON.parse(contents_hash)
-%>

<% "#{neoservers_hash}".each_pair do |id, ipaddress| %>
<%= "server.#{id}=#{ipaddress}:2888:3888" %>
<% end %>

当我尝试上传食谱时,我收到以下错误:

$ knife cookbook upload neo4j -E development
Uploading neo4j          [0.1.0]
FATAL: Erb template templates/default/coord.cfg.erb has a syntax error:
FATAL: -:7: syntax error, unexpected tIDENTIFIER, expecting '}'
FATAL:  _buf << ( "server.#{id}=#{ipaddress}:2888:3888" ).to_s; _buf << '
FATAL:                   ^
FATAL: -:8: unterminated string meets end of file
4

1 回答 1

1

您在这一行中有一个奇怪的语法:

<% "#{neoservers_hash".each_pair do |id, ipaddress| %>

您似乎尝试对neoserver_hash变量使用字符串评估,这实际上不起作用,就像neoserver_hash哈希而不是字符串一样。此外,您还缺少右括号。相反,您可能希望完全摆脱字符串评估并使用以下内容:

<% neoservers_hash.each_pair do |id, ipaddress| %>
于 2013-04-02T10:53:54.170 回答