Skip to content

clarification of cloud config user instantiation #1919

Description

@clanktron

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:

  1. top level users entry in your cloud-config file
  2. users entry in one of the stages layers of your cloud-config
  3. an ensure_entities statement at any of the stages layers
  4. baked into the container image

A few questions:

  • When a user is declared at the top level of a cloud-config file, is this applied at every boot or just the initial install?

The docs state that if you want to add a user post-install that you should add a users entry in the initramfs stage. This to me implies that all stages are 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 the users entry in your chosen stage? I initially did this but it seems that not having a top-level users declaration isn't valid syntax (kairos-agent validate states the rendered json is invalid).

  • What takes precedence in cloud config, users or ensure_entities? If both have overlapping entries how are these handled?

Say I have a users entry and an ensure_entities entry in the same "step" of a stage. Or say I have a user in the initramfs stage and an ensure_entities user in the fs stage. Is any sort of merging done here or is this just undefined/unsupported? In the docs only passwd and ssh_authorized_keys are evaluated if the user already exists, but this would only cover the situation where ensure_entities is used before users and not the other way around. I'm not necessarily interested in doing this but I think the behavior here should be clearly defined.

  • When can I expect users declared at the top level to be available?

I've tried doing some things as a certain user (with su or 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.

Oct 12 04:46:06 nas kairos-agent[1791]: ERRO[2023-10-12T04:46:06Z] chown: invalid user: ‘clayton:clayton’
Oct 12 04:46:06 nas kairos-agent[1791]: : failed to run chown -R clayton:clayton /scratch/dotfiles && su clayton -c "HOME=/home/clayton /scratch/dotfiles/install" >

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_entities or users in 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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status
Done ✅

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions