How to Run for each loop in template chef

自作多情 提交于 2020-01-25 14:33:13

问题


I have a attribute in the form of array, and i want to iterate over it in Chef template ?

<% node['db2']['instance_username'].each do |device| -%> 
  <%= "/home/#{device}/sqllib/lib64" %>
<% end -%>

I'm doing like this but it is giving error.


回答1:


<% 
node['db2']['instance_username'].each do |device| 
%> 
  /home/<%= device %>/sqllib/lib64
<% end %>

I'd rewrite it like this instead. If you are having an error try taking out the end hyphens out they are a rails construct and I'm not sure if they cross over well but it would help a lot if you posted the error you are having. Most likely instance username is not an array.



来源:https://stackoverflow.com/questions/27600349/how-to-run-for-each-loop-in-template-chef

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!