Prevent "lxc launch" from creating another "ubuntu" user

Hi,

I am using the latest snap version of LXD at the time of this writing on Ubuntu 18.04. I decided to customize the base ubuntu:lts container in order to install several packages and rename the default (ubuntu) user to ansible, remove its password, insert an .ssh/authorized_keys and such.

After my customizations I stop the container and then simply use lxc publish to generate an image that is “detached” from the upstream one (this is the intention here, btw).

However, if I then create a new container based on said customized image it creates a new user named ubuntu which then just happens to have the UID 1001 with an accompanying group of the same name and GID.

How can I suppress this behavior?

Actually what I am interested in is where this behavior originates and how to adjust that. My guess is that it has something to to with cloud-init or some hook that runs when lxc launch happens …

Thanks.

That’s likely cloud-init triggering. You could just remove the cloud-init package from the container.
cloud-init is triggered whenever the container changes name which happens in your case.

Hmm, thanks. So I guess I need to brush up on where cloud-init stores all its stuff. Evidently it’s not limited to the location you pointed out here (/var/lib/cloud/*). I have to admit that at this point it still is somewhat of a mystery to me. But I’ll get there and it seems to be a worthwhile subject for research.

Thanks for your time, Stéphane!

If I don’t forget it, I’ll update this post for the benefit of future visitors with my findings.