I’m trying to use LXC profile to write some files into a fresh container ( with cloud-init’s write_file module ) , and it’s working pretty well so far.
The only issue i have is that sometimes ( maybe when the file is too long ? ), it will mess up the formatting of the user.user-data part of the profile and try to write it as a single line using carriage return tag ( \n ).
For example here is the output of a lxc profile edit with a random file i created for this purpose
I re-tagged this question as a LXD question, since it is about LXD. LXC is the other implementation where the commands are of the form lxc-create, lxc-start, etc. See more at https://blog.simos.info/comparison-between-lxc-and-lxd/
The issue that you get, is related to the cloud-init section.
The source of the problem is when a line has an extra space at the end. Once you save the profile, the whole cloud-init section loses the formatting.