fix: create the runner's group before its account (CP-42) #22

Merged
pit merged 1 commit from hermes/cp42-runner-group into main 2026-11-06 18:40:40 +00:00
Owner

!21's deploy (run 58) failed on 145, and PROD is degraded until this merges: 143 has had use_remote_runner: true since 18:12:24 UTC, and no runner is registered. Any task started now errors. None has been started since the switch (checked at 18:2x: no task created after 18:12, GET /api/runners empty).

Summary

 # semaphore/service/roles/semaphore_runner/tasks/main.yml
+- name: system group for the runner
+  ansible.builtin.group:
+    name: "{{ semaphore_runner_group }}"
+    system: true
+
 - name: system user for the runner, no shell, no password
   ansible.builtin.user:
     group: "{{ semaphore_runner_group }}"

Cause. The user module's group: sets an account's primary group; it does not create one. 143 never hit this because the server role names no group, so useradd makes a user-private one. On 145 nothing had made semaphore:

TASK [semaphore_runner : system user for the runner, no shell, no password]
[ERROR]: Task failed: Module failed: Group semaphore does not exist
semaphore-runner : ok=17 changed=7 unreachable=0 failed=1

Why the rehearsal passed it. Under --check, an account that does not exist yet is reported as a change without the group being looked up. The comment above the new task says so, because no --check run will catch a regression here.

Also in this change: role refuses a missing runner token unset the token only from its own list. A shell that had sourced .env passed the real token through, so the refusal it asserts never fired. It now also does env -u on the inherited name.

Evidence

  • A real (non-check) run of the role's account section against a throwaway unprivileged Debian 13 container (the repo's Dockerfile.rehearsal, sshd, no init), from origin/main and then from this branch:
== origin/main's role (1 task(s) in the account section)
  [ERROR]: Task failed: Module failed: Group semaphore does not exist
  getent: no-group | no-user
== the fix branch's role (2 task(s) in the account section)
  TASK [system group for the runner]                          changed
  TASK [system user for the runner, no shell, no password]    changed
  getent: semaphore:x:997: | semaphore:x:996:997::/opt/semaphore-runner:/usr/sbin/nologin
  • make check → exit 0, env tests: every case passed., plan tests: every case passed. The package fixture still reports skip (no dpkg on the machine that ran it).
  • The test fix, against its own failure: SEMAPHORE_RUNNER_REGISTRATION_TOKEN=fake-inherited-token make env-test → every case passed. Before the fix, the same inherited name produced 4 case(s) FAILED.
  • make service-check against 143 and 145 → semaphore ok=32 changed=1 failed=0, semaphore-runner ok=21 changed=7 failed=0.
  • Not proven before merge: the rest of the runner play after the account task. Run 58 never reached it, and a container cannot run its unit tasks. Registration, the unit starting, and the third play marking the runner default are all first exercised by this merge's deploy.

Merge Danger

Door: two-way.

Merging re-runs the deploy. The server play is a no-op on 143 (the config already carries the switch and the token), so the deploy's real work is on 145: the group and user, then everything run 58 never reached.

Blast Radius: 145, plus one PUT /api/runners/<id> on 143.

If the runner play fails further on, PROD stays where it is now: degraded, no runner. To get tasks running again without a runner, revert semaphore_use_remote_runner to false and deploy.

!21's deploy (run 58) failed on 145, and **PROD is degraded until this merges**: 143 has had `use_remote_runner: true` since 18:12:24 UTC, and no runner is registered. Any task started now errors. None has been started since the switch (checked at 18:2x: no task created after 18:12, `GET /api/runners` empty). ## Summary ```diff # semaphore/service/roles/semaphore_runner/tasks/main.yml +- name: system group for the runner + ansible.builtin.group: + name: "{{ semaphore_runner_group }}" + system: true + - name: system user for the runner, no shell, no password ansible.builtin.user: group: "{{ semaphore_runner_group }}" ``` **Cause.** The `user` module's `group:` sets an account's primary group; it does not create one. 143 never hit this because the server role names no group, so `useradd` makes a user-private one. On 145 nothing had made `semaphore`: ``` TASK [semaphore_runner : system user for the runner, no shell, no password] [ERROR]: Task failed: Module failed: Group semaphore does not exist semaphore-runner : ok=17 changed=7 unreachable=0 failed=1 ``` **Why the rehearsal passed it.** Under `--check`, an account that does not exist yet is reported as a change without the group being looked up. The comment above the new task says so, because no `--check` run will catch a regression here. **Also in this change:** `role refuses a missing runner token` unset the token only from its own list. A shell that had sourced `.env` passed the real token through, so the refusal it asserts never fired. It now also does `env -u` on the inherited name. ## Evidence - A real (non-check) run of the role's account section against a throwaway unprivileged Debian 13 container (the repo's `Dockerfile.rehearsal`, sshd, no init), from `origin/main` and then from this branch: ``` == origin/main's role (1 task(s) in the account section) [ERROR]: Task failed: Module failed: Group semaphore does not exist getent: no-group | no-user == the fix branch's role (2 task(s) in the account section) TASK [system group for the runner] changed TASK [system user for the runner, no shell, no password] changed getent: semaphore:x:997: | semaphore:x:996:997::/opt/semaphore-runner:/usr/sbin/nologin ``` - `make check` → exit 0, `env tests: every case passed.`, `plan tests: every case passed.` The package fixture still reports `skip` (no `dpkg` on the machine that ran it). - The test fix, against its own failure: `SEMAPHORE_RUNNER_REGISTRATION_TOKEN=fake-inherited-token make env-test` → `every case passed`. Before the fix, the same inherited name produced `4 case(s) FAILED`. - `make service-check` against 143 and 145 → `semaphore ok=32 changed=1 failed=0`, `semaphore-runner ok=21 changed=7 failed=0`. - **Not proven before merge:** the rest of the runner play after the account task. Run 58 never reached it, and a container cannot run its unit tasks. Registration, the unit starting, and the third play marking the runner default are all first exercised by this merge's deploy. ## Merge Danger **Door:** two-way. Merging re-runs the deploy. The server play is a no-op on 143 (the config already carries the switch and the token), so the deploy's real work is on 145: the group and user, then everything run 58 never reached. **Blast Radius:** 145, plus one `PUT /api/runners/<id>` on 143. If the runner play fails further on, PROD stays where it is now: degraded, no runner. To get tasks running again without a runner, revert `semaphore_use_remote_runner` to `false` and deploy.
fix: create the runner's group before its account (CP-42)
All checks were successful
plan / guest-plan-check (pull_request_target) Successful in 17s
pr-checks / check (pull_request) Successful in 40s
51ca3cdf94
The first deploy of the runner role stopped on 145 at the account task:
"Group semaphore does not exist". The user module's group: sets an
account's primary group and does not create one, and on 145 nothing
had made it. --check could not see it, because an account that does not
exist yet is reported as a change without the group being looked up.

Also: the missing-runner-token case unset the token only from its own
list, so a shell that had sourced .env passed the real token through and
the refusal never fired.
Member

Review started (round 1/5) on 51ca3cdf94 — reading the diff now.

**Review started** (round 1/5) on 51ca3cdf94a7d40f75532b5ba644b2d3b023e562 — reading the diff now.
bot-minos approved these changes 2026-11-06 18:24:58 +00:00
bot-minos left a comment

repo=olympus/infra-cockpit pr=22 head=51ca3cdf94a7d40f75532b5ba644b2d3b023e562 round=1/5 verdict=merge

Recommendation: merge

Round 1 of 5. No earlier review on this thread (list_pull_reviews was empty), so the whole head is reviewed against base baa757b (git merge-base --is-ancestor baa757b 51ca3cd true; delta = 2 files, +17/-3).

Spec: CP-42 (Vikunja project 11, index 42) plus the PR body. The PR is a follow-up fix to !21's deploy (run 58), so the contract is the body's: create the runner's group before the account that names it, and make the refusal test independent of an inherited token.
Standards: AGENTS.md (read at head). §Toolchain: "make check is the one command that needs no credential"; §Pull requests: name the task as CP-<index>. No docs/adr/ in this repo; no other written convention bears on the diff.

Standards

No BLOCKER.

  • ADVISORY — semaphore/service/roles/semaphore_runner/tasks/main.yml:146 — nothing in make check pins the new group task. The comment at main.yml:140-145 says no --check run catches this regression, so a deterministic guard is the only thing that would. The repo already has the shape for it: scripts/tests/run.sh:527 (case_the_third_play_runs_the_runner_default_file) and :588 (case_the_runner_play_runs_the_token_mode_file) read --list-tasks for a task by name and for its order. Evidence (mutation): I deleted the system group for the runner task at head and ran mise exec -- make check → rc=0, 0 FAIL lines. The next edit to this block can drop the group and go green, which is the failure that put PROD in its current state. Clearing change: one case asserting semaphore_runner : system group for the runner appears in play #2 before semaphore_runner : system user for the runner, no shell, no password (the head's --list-tasks lists them at positions 70 and 71 of the log).

Spec

No BLOCKER. Both claims reproduced:

  • The cause is as stated. ansible/modules/user.py:753 (the installed module) is fail_json(msg="Group %s does not exist" % self.group); user with group: sets the primary group and does not create it. The new ansible.builtin.group task (main.yml:146-149, system: true, same {{ semaphore_runner_group }} variable the user task uses at :153) sits directly above the user task (:151) in section 2, before any task that uses the group (:164, :178, …). It is idempotent by construction (group is a no-op when the group exists), so the same task is safe on 143-style guests where a package already made it.
  • The test fix is real. scripts/tests/run.sh:276 and :293 add env -u SEMAPHORE_RUNNER_REGISTRATION_TOKEN. Red/green pair, run by me with SEMAPHORE_RUNNER_REGISTRATION_TOKEN=fake-inherited-token make env-test: base baa757b → rc=2, env tests: 4 case(s) FAILED; head → rc=0, env tests: every case passed. The author's "4 case(s) FAILED before" is exact. Clean-environment make env-test passes at base and head.

Verified by hand

Check Result
Pull ref resolves to dispatch SHA (ls-remote refs/pull/22/head, before and after the probes) 51ca3cdf… both times
mise exec -- make check at head rc=0 (env tests, plan tests, tofu fmt all pass)
ansible-playbook … site.yml --syntax-check, --list-tasks at head rc=0; group task listed immediately before the user task in play #2
Inherited-token red/green (above) base 4 FAILED, head all passed
Mutation: group task deleted, make check rc=0 (the advisory above)
git status --porcelain at head after all probes empty
CI by SHA (commit status API) success, 2 contexts (plan / guest-plan-check green, second context also success)

Not verified

  • The author's real (non-check) run in a throwaway Debian 13 container. I have no container runtime and no root here, so I cannot create a group or user. What I did verify is the mechanism the evidence rests on (user.py:753) and the task order in the playbook. The fix is small and the module semantics are as the body states.
  • The rest of the runner play after the account task (registration, the unit starting, the third play marking the runner default). The body says so itself; run 58 never reached it and a container cannot run the unit tasks. This is the first exercise of that path, as disclosed.

Named, not charged

  • The test-only change (run.sh) rides in the same PR as the role fix. The body discloses it under "Also in this change"; it is small and tied to the same CP-42 work, so it is not counted.
  • Merge Danger section: door "two-way", blast radius 145 plus one PUT /api/runners/<id> on 143, and the revert path (semaphore_use_remote_runner: false). Consistent with the diff; nothing in the diff touches 143's config.

Summary

Axis Findings Worst
Standards 1 (0 BLOCKER, 1 ADVISORY) ADVISORY: no make check case pins the group task (main.yml:146)
Spec 0 none; both claims reproduced

The change does what it says, breaks nothing I could find, and make check is green. One advisory travels as advice, and the count (1) does not trip the volume rule. Merge.

<!-- minos review-loop: repo=olympus/infra-cockpit pr=22 head=51ca3cdf94a7d40f75532b5ba644b2d3b023e562 round=1/5 axes=standards,spec --> repo=olympus/infra-cockpit pr=22 head=51ca3cdf94a7d40f75532b5ba644b2d3b023e562 round=1/5 verdict=merge Recommendation: merge Round 1 of 5. No earlier review on this thread (`list_pull_reviews` was empty), so the whole head is reviewed against base `baa757b` (`git merge-base --is-ancestor baa757b 51ca3cd` true; delta = 2 files, +17/-3). **Spec:** CP-42 (Vikunja project 11, index 42) plus the PR body. The PR is a follow-up fix to !21's deploy (run 58), so the contract is the body's: create the runner's group before the account that names it, and make the refusal test independent of an inherited token. **Standards:** `AGENTS.md` (read at head). §Toolchain: "`make check` is the one command that needs no credential"; §Pull requests: name the task as `CP-<index>`. No `docs/adr/` in this repo; no other written convention bears on the diff. ## Standards No BLOCKER. - ADVISORY — `semaphore/service/roles/semaphore_runner/tasks/main.yml:146` — nothing in `make check` pins the new group task. The comment at `main.yml:140-145` says no `--check` run catches this regression, so a deterministic guard is the only thing that would. The repo already has the shape for it: `scripts/tests/run.sh:527` (`case_the_third_play_runs_the_runner_default_file`) and `:588` (`case_the_runner_play_runs_the_token_mode_file`) read `--list-tasks` for a task by name and for its order. Evidence (mutation): I deleted the `system group for the runner` task at head and ran `mise exec -- make check` → rc=0, 0 FAIL lines. The next edit to this block can drop the group and go green, which is the failure that put PROD in its current state. Clearing change: one case asserting `semaphore_runner : system group for the runner` appears in play #2 before `semaphore_runner : system user for the runner, no shell, no password` (the head's `--list-tasks` lists them at positions 70 and 71 of the log). ## Spec No BLOCKER. Both claims reproduced: - The cause is as stated. `ansible/modules/user.py:753` (the installed module) is `fail_json(msg="Group %s does not exist" % self.group)`; `user` with `group:` sets the primary group and does not create it. The new `ansible.builtin.group` task (`main.yml:146-149`, `system: true`, same `{{ semaphore_runner_group }}` variable the user task uses at `:153`) sits directly above the user task (`:151`) in section 2, before any task that uses the group (`:164`, `:178`, …). It is idempotent by construction (`group` is a no-op when the group exists), so the same task is safe on 143-style guests where a package already made it. - The test fix is real. `scripts/tests/run.sh:276` and `:293` add `env -u SEMAPHORE_RUNNER_REGISTRATION_TOKEN`. Red/green pair, run by me with `SEMAPHORE_RUNNER_REGISTRATION_TOKEN=fake-inherited-token make env-test`: base `baa757b` → rc=2, `env tests: 4 case(s) FAILED`; head → rc=0, `env tests: every case passed.` The author's "4 case(s) FAILED before" is exact. Clean-environment `make env-test` passes at base and head. ## Verified by hand | Check | Result | |---|---| | Pull ref resolves to dispatch SHA (`ls-remote refs/pull/22/head`, before and after the probes) | `51ca3cdf…` both times | | `mise exec -- make check` at head | rc=0 (env tests, plan tests, `tofu fmt` all pass) | | `ansible-playbook … site.yml --syntax-check`, `--list-tasks` at head | rc=0; group task listed immediately before the user task in play #2 | | Inherited-token red/green (above) | base 4 FAILED, head all passed | | Mutation: group task deleted, `make check` | rc=0 (the advisory above) | | `git status --porcelain` at head after all probes | empty | | CI by SHA (commit status API) | `success`, 2 contexts (plan / guest-plan-check green, second context also success) | ## Not verified - The author's real (non-check) run in a throwaway Debian 13 container. I have no container runtime and no root here, so I cannot create a group or user. What I did verify is the mechanism the evidence rests on (`user.py:753`) and the task order in the playbook. The fix is small and the module semantics are as the body states. - The rest of the runner play after the account task (registration, the unit starting, the third play marking the runner default). The body says so itself; run 58 never reached it and a container cannot run the unit tasks. This is the first exercise of that path, as disclosed. ## Named, not charged - The test-only change (`run.sh`) rides in the same PR as the role fix. The body discloses it under "Also in this change"; it is small and tied to the same CP-42 work, so it is not counted. - Merge Danger section: door "two-way", blast radius 145 plus one `PUT /api/runners/<id>` on 143, and the revert path (`semaphore_use_remote_runner: false`). Consistent with the diff; nothing in the diff touches 143's config. ## Summary | Axis | Findings | Worst | |---|---|---| | Standards | 1 (0 BLOCKER, 1 ADVISORY) | ADVISORY: no `make check` case pins the group task (`main.yml:146`) | | Spec | 0 | none; both claims reproduced | The change does what it says, breaks nothing I could find, and `make check` is green. One advisory travels as advice, and the count (1) does not trip the volume rule. Merge.
pit merged commit 1f07290047 into main 2026-11-06 18:40:40 +00:00
pit deleted branch hermes/cp42-runner-group 2026-11-06 18:40:41 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
olympus/infra-cockpit!22
No description provided.