[SOLVED] When using cloud-init, what order are the users created in?
Linux - Virtualization and CloudThis forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
When the VM boots up for the first time using an ISO file generated from that user-data file, the users are created. From what I see in /etc/passwd, the "auser" user is created with UID 1000, and the "muser" user is created with UID 1001.
We are deploying some software on this VM that needs to know the UID of "muser" in advance prior to installation. (This is due to needing to create a Docker image on a machine that's different from the machine where the software will be installed.) Whenever a VM is deployed using that ISO file, will "muser" always be created after "auser" (and therefore "muser" will always have UID 1001)?
I thought maybe the users were created in either alphabetical order or in the reverse order in which they are listed in the user-data file, so I created another user-data file with 4 users to test that theory. But that theory failed, and I could not tell in what order cloud-init creates the users.
If no one knows what order the users are created in, can I at least assume that "muser" will always have a UID of 1001?
I haven't done cloud-init at all but this post seems to suggest you can specify uid (and maybe gid) in your config file so you always assign the ones you want rather than worrying about what it would pick at random. It does note you have to put quotes around the values specified.
Now, the users key has a list of users as value, which could mean that users are created in the list order. However, the documentation doesn’t mention this.
I haven't done cloud-init at all but this post seems to suggest you can specify uid (and maybe gid) in your config file so you always assign the ones you want rather than worrying about what it would pick at random. It does note you have to put quotes around the values specified.
Thanks, adding uid worked, although as mentioned in that post, there is a bug so you have to put it in quotes like:
Glad I could help. If you don't mind, please go to thread tools and marked this as Solved. It helps others in future more quickly find posts with solutions.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.