I’m attempting to set user.user-data on an already created container, however as far as I can tell, it has not actually done anything to the container.
I’ve checked /var/lib/cloud/instance/user-data.txt and it appears to just have the blank placeholder in there.
Is user.user-data a special configuration that is only set once on launch?
I am aware that cloud-init is typically an inital configuration tool, however I’m doing a cloud-init clean before exporting my instance to allow for further deployment, so it does make sense to allow for user-data to be edited even after a container is spawned in my case.
Perhaps I’ve just missed it, but is there a canonical way to create a new LXD image (using lxc publish and lxc image export) which allows for the use of cloud-init (and configuration of that through user.user-data)?
E.g: I create a container using lxc launch ubuntu:20.04, make some changes to it, install some new software, and then I’d like to save an image of that container which can then be imported and launched (with cloud-init working fully with user.user-data).
For now I’ll just be running cloud-init clean and exporting as described, and then setting this apply_template you suggested.
If you run cloud-init clean, then stop the instance and publish it as a new image, instances created from that new image will get apply_template=create set during creation and so will run cloud-init.