Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append with cloud-init write_files

Tags:

cloud-init

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!"
  }
]
like image 873
Brad Avatar asked Nov 28 '18 23:11

Brad


People also ask

Where do I put cloud-init files?

Cloud-init config is provided in two places: /etc/cloud/cloud. cfg. /etc/cloud/cloud.

Does cloud-init run every boot?

Short description. By default, user data scripts and cloud-init directives run only during the first boot cycle when an EC2 instance is launched. However, you can configure your user data script and cloud-init directives with a mime multi-part file.

Is cloud-init required?

Cloud-init is a package that contains utilities for early initialization of cloud instances. It is needed in Arch Linux images that are built with the intention of being launched in cloud environments like OpenStack, AWS etc.


1 Answers

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
like image 160
dangel Avatar answered Jan 03 '23 18:01

dangel