Chef infra chef shell out to hash(分隔符是新行)

Chef infra chef shell out to hash(分隔符是新行),chef-infra,mixlib-shellout,Chef Infra,Mixlib Shellout,我有一个食谱,内容如下: echo_example = shell_out("echo "line 1\nline 2") if echo_example.exitstatus == 0 && echo_example node.rm('test') node.set['test'] = [echo_example.stdout.chomp] end 刀的属性输出为: "test": [ "line 1\nline 2"

我有一个食谱,内容如下:

echo_example = shell_out("echo "line 1\nline 2")
if echo_example.exitstatus == 0 && echo_example
  node.rm('test')
  node.set['test'] = [echo_example.stdout.chomp]
end
刀的属性输出为:

        "test": [
          "line 1\nline 2"
        ]
如何使用下面的刀获得此输出

        "test": [
          "line 1",
          "line 2"
        ]

谢谢

我不知道这是否是您正在寻找的,但也许您可以在将其放入属性之前,在配方中拆分输出。您可以为此使用:

node.set['test']=[echo\u example.stdout.chomp.split(“\n”)]

谢谢,这真的将属性分开了。