How to unmangle `user.user-data` section

I created and customized a profile and was adding runcmd lines as I was making progress with customization. user-data looked like this:

  user.user-data: |
    #cloud-config
    package_upgrade: true

After some 100+ lines in user.user-data section, the next lxc profile edit myprofile revealed the profile in this format:

user.user-data: "#cloud-config\npackage_upgrade: true\n...."

I searched the Github issues and this forum; there’s a post about lxc list that shows how to produce output in YAML or JSON but it doesn’t work with profile show.

As the profile format is now impossible to work with, I can manually fix the formatting, but it’s going to take me 10-15 minutes and I’d prefer to avoid having to repeat that in the future.

Any ideas?

For next time it might be better to work in a file then load that file into your profile I.E

lxc profile set PROFILE_NAME user.user-data - < /path/to/yaml.yaml

Alternatively LXDMosaic can do some basic cloud-config management and the latest RC versions can start watching the cloud-init-output.log for you with some basic error highlighting;

1 Like