Replies: 4 comments 1 reply
|
Hi @clanktron The users at the top level is mainly for backwards compatibility with cloud config. Because yip supports a subset of cloud-config, is possible to set it at the top level. IMO we should have dropped that a long time ago and only support stages but it has to be maintained due to backwards compatibility.
Indeed stages are run on each boot.
Its only a warning, as its optional to set the users there, we emit a warning but not having users in there should be ok. In fact our test suite does not have the users at the top level: https://github.com/kairos-io/kairos/blob/master/tests/assets/autoinstall.yaml
Good question, I have no idea :) Let me look that up and come back to you.
As mentioned above they are created on the "boot" stage. The following stages are available and in the following order:
So your top level users will be available during the boot stage. If you want to use them then your configs should be done on that stage or later and after the user creation (lexicographic order) That is why on our own stuff we create them during initramfs and usually as soon as possible: https://github.com/kairos-io/packages/blob/main/packages/static/kairos-overlay-files/files/system/oem/10_accounting.yaml Let me come back at you with the users/ensure_entities answer |
No merging, users uses the ensure_entities lib underneath, and they both check if the user exists before doing anything, so no matter what, they will not overlap. Then it comes to the ordering of the plugins, in our case, ensure_entities goes first then Users https://github.com/kairos-io/kairos-agent/blob/main/pkg/cloudinit/cloudinit.go#L42 Then it also comes to the files and ordering of the files and stages and steps. If your user stanza is on initramfs it will be created before a entitites in a fs stage for example. And if your user stanza is in a file called So the only issue is if you have them in the same file, same stage, same step. In that case, entitites will go first and then users, but they wont be recreated. So after all user is a more user-friendly way of denifing users, while entities is a more complex and complete system to generate /etc/passwd , /etc/shadow and /etc/groups files. |
|
@clanktron moved this to a discussion which seems more appropiate :) |
|
@Itxaka thanks for the comprehensive explanation! I was still having that issue with the clayton user not being available in the fs stage despite instantiating it at the top level (so boot stage), but I'll be retrying that again soon so I'll report back. On another note, is more of the official cloud-init user spec planned on being supported? Namely some of the fields I mentioned like |
Uh oh!
There was an error while loading. Please reload this page.
In the spirit of kairos being immutable, and considering I don't see /etc/passwd included in the COS_PERSISTENT partition, I'm assuming users/groups are reconstructed after every boot. This is great, what I'm confused about is how user lifecycle management is support to work declaratively.
There seems to be 4 ways to instantiate a user:
usersentry in your cloud-config fileusersentry in one of the stages layers of your cloud-configensure_entitiesstatement at any of the stages layersA few questions:
The docs state that if you want to add a user post-install that you should add a
usersentry in the initramfs stage. This to me implies that allstagesare run at every boot, and that the top-level declarations are only pertinent for the initial install. If this is the case, why not skip the top-level entirely and only put theusersentry in your chosenstage? I initially did this but it seems that not having a top-level users declaration isn't valid syntax (kairos-agent validatestates the rendered json is invalid).usersorensure_entities? If both have overlapping entries how are these handled?Say I have a
usersentry and anensure_entitiesentry in the same "step" of a stage. Or say I have auserin the initramfs stage and anensure_entitiesuser in the fs stage. Is any sort of merging done here or is this just undefined/unsupported? In the docs onlypasswdandssh_authorized_keysare evaluated if the user already exists, but this would only cover the situation whereensure_entitiesis used beforeusersand not the other way around. I'm not necessarily interested in doing this but I think the behavior here should be clearly defined.I've tried doing some things as a certain user (with
suor just changing some directory/file permissions etc) in the stages section. But it seems that none of my created users are available on the system at this point? My users are available by the time I can log in via console/ssh so that's not the issue.For example, the following error is a step in my cloud config that runs at the fs stage.
I assumed that fs was the "final" stage and that I could use my users by this point/stage (I assumed I could use them at any stage to be honest). When can I assume they'll be available? If I want do user related things do I have to add an
ensure_entitiesorusersin a prior stage (or at least before the step on the same stage) as opposed to a top-level instantiation?This next question could almost be categorized as a separate issue, but it seems mildly related so I thought I'd include it here. Is more of the "real" cloud init spec going to be supported in the future? Namely user fields like
sudo:,doas:,expiredate:, etc.All reactions