How do you create pretty json in CHEF (ruby)

后端 未结 3 1147
予麋鹿
予麋鹿 2021-02-09 16:58

How would you make an erb template that has human readable json?

The following code works, but it makes a flat json file

default.rb

default[\'         


        
3条回答
  •  佛祖请我去吃肉
    2021-02-09 17:41

    Something like this would also work:

    file "/var/my-file.json" do
      content Chef::JSONCompat.to_json_pretty(node['foo']['bar'].to_hash)
    end
    

提交回复
热议问题