You can scroll through the list in the template instead of adding control characters to the string.
Recipe:
$ cat test.rb node.set['apples'] = %W(Cortland Red\ Delicious Golden\ Delicious Empire Fuji Gala) template "test" do local true source "./test.erb" end
A template using rubys join to add the characters you need at the end of each element:
$ cat test.erb <%= node['apples'].join(",\n") %>
Result:
$ chef-apply test.rb Recipe: (chef-apply cookbook)::(chef-apply recipe) * template[test] action create - create new file test - update content in file test from none to 70d960 --- test 2015-08-02 12:32:23.000000000 -0500 +++ /var/folders/r6/9h72_qg11f18brxvpdpn6lbm0000gn/T/chef-rendered-template20150802-76337-130h5sl 2015-08-02 12:32:23.000000000 -0500 @@ -1 +1,8 @@ +Cortland, +Red, +Delicious, +Golden Delicious, +Empire, +Fuji, +Gala
You can also look at Rubys split to turn a string into a list. http://ruby-doc.org/core-2.2.0/String.html#method-i-split
Edited to add in ,\n , as in the original request.
source share