在廚師,屬性看起來如下:如何把每個數組元素,在雙引號
default['cluster']['ipaddress'] = ["10.211.130.108", "10.211.242.203"]
在廚師的食譜,我已經把每個數組元素,在雙引號,使用map
:
json_nodes = node['consul']['cluster']['ipaddress'].map { |s| "#{s.to_s}:8300" }
bash 'configuring file.json' do
code <<-EOH
echo #{json_nodes} > "/home/user1/file.json"
EOH
end
我得到的文件/home/user1/file.json
內輸出如下:
[10.211.130.108:8300, 10.211.242.203:8300]
釷Ë輸出應該有雙引號,如下所示:
["10.211.130.108:8300", "10.211.242.203:8300"]
輸出是真的如你所描述的,不'「10.211.130.108:8300,10.211.242.203:8300」'? – StephenKing
你如何在廚師「輸出」這個? – StephenKing
我編輯了我的問題。請幫助我。謝謝@StephenKing – meallhour