Search code examples
chef-infrachef-recipecookbook

How can I create a simple text file that contains more than one line of text with CHEF?


I am trying to create a CHEF recipe that creates a text file with more than one line of text for testing purposes. I have tried using content but that just wrote out to one line. I have searched for a few hours now and still have not found a good way to do this. Is there a better way to do it instead of using content?


Solution

  • You would use either the file resource or template resource, depending on if you wanted simple inline content, or a more complex Erb template:

    file '/foo' do
      content "line one\nline two\n"
    end