How can I prime a previously started container again with cloud-init?

In LXD I am customizing one of the Ubuntu upstream images and the using lxc publish to convert that to an image again. How can I prime the image again in order for cloud-init to run?

The goal is to apply the name of the container, generate fresh SSH keys for the sshd and so on, whenever I init or launch based on my customized image …

Also, can the priming at all be done after lxc publish or is that something that should be done on the stopped container before the lxc publish step?

Thanks!

NB: I already saw this article by @simos as well as this question and neither touch on the topic of resetting or priming again the cloud-init of a container that was started at least once.

I think you need to wipe /var/lib/cloud/* in the container prior to publishing it.

Wow, that’s all there is to it? Well, thanks, I’ll give that a try and report back.

Thanks, this seems to have done it.

#cloud-init status tells you if if its been run or is running.
#cloud-init clean will cause it to rerun next reboot