Within Chef, the attribute looks as below:
default['cluster']['ipaddress'] = ["10.211.130.108", "10.211.242.203"]
Within Chef recipe, I have put every array element in double quotes, using 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
I get the following output within the file /home/user1/file.json:
[10.211.130.108:8300, 10.211.242.203:8300]
The output should have double quotes as follows:
["10.211.130.108:8300", "10.211.242.203:8300"]
"10.211.130.108:8300,10.211.242.203:8300"?