17

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!"
  }
]
Brad
  • 159,648
  • 54
  • 349
  • 530

2 Answers2

20

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
dangel
  • 7,238
  • 7
  • 48
  • 74
19

It was not possible, but I added the functionality and raised a merge request which was subsequently approved.

The functionality is available from 18.5 onwards.

James Baxter
  • 1,237
  • 9
  • 17
  • Awesome! Thanks. Looking forward to using the change in the future. – Brad Dec 02 '18 at 14:36
  • 2
    I think the functionality as been released already since the link says merged to master on 2018-12-06 ? It would be good if you can edit your answer as the documentation seems not up to date – 3pns Mar 17 '19 at 11:44