feat(runner_account): support a differently named primary group#29
Merged
Conversation
The runner_account struct gains an optional `group` key naming the account's primary group. It defaults to the account name, so existing hosts render and apply identically; set it for an externally provisioned account whose primary group is named differently (account ci-worker, group ci), where the account name is not itself a resolvable group and the first apply would otherwise fail to find it. The group is derived once (falling back to the name) and threaded into every group ownership the module manages: the managed group and the user's gid where the account is owned here, and the group of the runner configuration file, its directory, the .runner_system_id file, and the account's systemd user tree. Owners stay the account name throughout. The module data layer cannot express "same as name", so the default is an absent key with the fallback resolved in code.
The `ci-worker`/`ci` pair in the runner_account.group option doc and the README is an example, not a default or a shipped name. Prefix it with "e.g." so it does not read as a fixed value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #25.
Changes
The
runner_accountstruct gains an optionalgroupkey naming the account's primary group. It defaults to the account name, so existing hosts render and apply identically; set it when an externally provisioned account's primary group is named differently from the account (e.g. accountci-worker, primary groupci).On Linux, a file (and a user account) has both an owner and a group. The module used the account name for both, so it worked only when the account's primary group shared the account's name. An externally created account whose group is named differently then failed on its first apply: the module tried to use the account name as the group, and no such group exists.
groupseparates the two. The account name still owns everything the module creates; thegroupvalue is used wherever the module sets a group: the group and primary group it gives the account when it manages the account, and the group of the runner configuration file, its directory, the.runner_system_idfile, and the account's~/.config/systemd/userfolder.The default is an absent key with the fallback resolved once in code, because the module data layer cannot express "same as the account name". Unset, the account name doubles as the group, which is correct by construction where the module creates the account.
Verification
groupinto every derived resource (extending the ownership-derivation context for the externally-owned case, plus the managed-account case for the group resource and the user'sgid), and assert the default falls back to the account name. Both directions are mutation-checked: breaking the derivation fails exactly the custom-group cases while the fallback cases stay green.puppet-lint,metadata-json-lint,yamllint, and theREFERENCE.mddocs check.