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


#1

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.


(Stéphane Graber) #2

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


#3

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


#4

Thanks, this seems to have done it.