Search code examples
cloud-init

Append with cloud-init write_files


When using write_files with cloud-init, is it possible to append content? If so, how?

write_files: [
  {
    "path": "/home/user/some-file",
    "content": "\nLine to append!"
  }
]

Solution

  • per https://cloudinit.readthedocs.io/en/latest/topics/modules.html#write-files

    write_files:
      - path: /home/user/some-file
        content: | 
           Line to append!
        append: true