【发布时间】:2016-10-27 03:23:33
【问题描述】:
我的节点上有一个可选属性。如果该属性存在,我希望我的模板只设置一个特定值:
<% if node['haproxy']['server']['backup'] %>
server <%= node['haproxy']['server']['backup']['hostname'] %> <%= node['haproxy']['server']['backup']['ipaddress'] %>:<%= node['mysql']['port'] %> weight 1 maxconn 100 check
<% end %>
这对我来说看起来不错,但是当我运行它时出现以下错误:
Chef::Mixin::Template::TemplateError
------------------------------------
no implicit conversion of String into Integer
我怎样才能让它工作,以便 Chef 识别该属性是否已设置?
【问题讨论】:
-
原来我需要使用对象而不是数组。
标签: attributes chef-infra