cloud-init vm with specific UID/GID

fonze98

Member
Oct 15, 2022
14
1
8
I am wondering if it is possible to specify the UID/GID that the user that is created with cloud-init vm template images uses?

With my current setup when I use the VM template for an Ubuntu server it creates a user with uid 1000. I need this user to have UID of 3000 so I have to log in create another user with sudo, switch over, change the UID/GID of the first user, switch user again verify it changed then remove the second user.

I would love to find a simpler way to do this.
 
you need to use custom cloud-init, ie "-cicustom":
https://cloudinit.readthedocs.io/en/stable/reference/modules.html#users-and-groups:~:text=uid: (integer/string) The user’s ID. Default is next available value..

PS if you want to stick with non-custom is to have template with user ids from 1000 to 2999 pre-created, since it uses next available id. Not sure if that qualifies as "simpler".


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Last edited:
So I have made a couple of clones from the template with the custom user cloud init yml. and found that after using the --cicustom when you clone the template it no longer fills in the hostname using the name you give in the GUI. I did a search on this and found this post but I am not following how they are using the vendor config to set the hostname correctly. Am I missing another component to make this work or do I just need to manually set the hostnames after using the cicustom flags for userdata?