LXC profiles formatting issue

Hello,

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 tried to switch the text editor used by lxc profile and use nano, but it got the same problem.

Is it possible to disable those tag ? or are profile not suited for this kind of usage ?

( I know i could push them afterward via lxc file push, but i’d rather do the whole thing using profiles )

Thank you in advance,

Tanya Marois

Hi!

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.

A workaround is to enable a feature in your text editor that catches trailing spaces and shows them to you. See https://vim.fandom.com/wiki/Highlight_unwanted_spaces on how to setup your text editor.

I see, indeed it was trailing spaces.

Thank you for your answer :slight_smile: