Credential boundary setup in ansible-homelab-mono #184

Closed
opened 2026-11-22 15:25:14 +00:00 by Claude · 3 comments
Owner

Part of #166

Question

Set up, in ansible-homelab-mono, the credential boundary that ADR-0032 (Credentials, not hooks, are the agent safety boundary) makes the real control. The destination test can't run safely without it. Produce a checklist and work through it with the human, since most of it needs admin rights the agent doesn't hold:

  • a dedicated Gitea bot user for agent sessions, with token scopes set;
  • branch protection on main: an approvals allowlist of humans only, dismiss stale approvals, the bot kept off the merge allowlist, protected file patterns (agent config, AGENTS.md, .gitea/workflows/, tests), required status checks;
  • the PR dry run (--check --diff, flux diff) as a required status check plus a PR comment, and how much of it the existing provision.yml already provides;
  • a CI check that fails if test paths changed after the test author's commit;
  • a read-only kubeconfig for agents bound to view, plus an aggregated read-only SealedSecret role;
  • the human allowlist for gate labels, recorded for docs/agents/delivery.md.

The resolution records what was done and the resulting facts later tickets depend on: the bot username, the kubeconfig's location (not its contents), and the status-check names.

Part of #166 ## Question Set up, in `ansible-homelab-mono`, the credential boundary that ADR-0032 (*Credentials, not hooks, are the agent safety boundary*) makes the real control. The destination test can't run safely without it. Produce a checklist and work through it with the human, since most of it needs admin rights the agent doesn't hold: - a dedicated Gitea bot user for agent sessions, with token scopes set; - branch protection on `main`: an approvals allowlist of humans only, dismiss stale approvals, the bot kept off the merge allowlist, protected file patterns (agent config, AGENTS.md, `.gitea/workflows/`, tests), required status checks; - the PR dry run (`--check --diff`, `flux diff`) as a required status check plus a PR comment, and how much of it the existing `provision.yml` already provides; - a CI check that fails if test paths changed after the test author's commit; - a read-only kubeconfig for agents bound to `view`, plus an aggregated read-only `SealedSecret` role; - the human allowlist for gate labels, recorded for `docs/agents/delivery.md`. The resolution records what was done and the resulting facts later tickets depend on: the bot username, the kubeconfig's location (not its contents), and the status-check names.
Claude added this to the Map: Infra and agent-team packages milestone 2026-11-22 15:25:14 +00:00
Claude added the Wayfinder/Task label 2026-11-22 15:25:14 +00:00
Claude added a new dependency 2026-11-22 16:09:28 +00:00
Defame1297 was assigned by Claude 2026-11-22 16:58:46 +00:00
Author
Owner

Working checklist (not the resolution)

Survey findings (2026-11-22)

  • Agent sessions run as root on the dev box. Root can read the real vault password (/root/ansible/.ansible/vault-pass.txt), the SSH key (/root/.ssh/id_ed25519) and an admin kubeconfig that KUBECONFIG already points at (/root/ansible/.kube/config). kubectl auth can-i delete pods -A and get secrets -A both answer yes. File contents were not read.
  • Pushing branches = reaching repo secrets. .gitea/workflows/molecule.yml:10-21 documents that anyone who can push branches can read ANSIBLE_VAULT_PASSWORD and SSH_PRIVATE_KEY through a workflow. Protected file patterns block the merge, not the run.
  • Ansible dry run is post-merge only. In provision.yml, each stage's --check --diff runs after merge, non-blocking (continue-on-error), in the apply job with the real secrets. Nothing runs before merge. Split out to Pre-merge Ansible dry run without exposing production credentials.
  • Lint is a PR check already. Ansible Lint Validation / lint_ansible (pull_request) runs on every PR with no secrets. Whether branch protection requires it is unverified.
  • No Flux PR check exists.
  • sealed-secrets-backup/sealed-secrets-keys-backup.yaml is tracked but vault-encrypted (header only checked). It is a Never-tier read target.

Decisions taken with the owner this session

  • Sessions keep running as root for now. The separate unix user is deferred to Agent unix user for delivery sessions, which blocks nothing. Accepted risk: until then, an agent session can read the vault password, the SSH key and the admin kubeconfig. On this box the credential boundary is a guardrail, not a boundary. Partial fix: delivery sessions export KUBECONFIG pointing at the read-only kubeconfig, so accidental cluster writes fail.
  • The bot is the existing Claude Gitea user (not a new account).
  • The bot pushes same-repo branches. Accepted risk: the bot can reach the repo's production secrets through a branch workflow.
  • Ansible pre-merge dry run: split to its own grilling ticket. This ticket covers the Flux dry run and the rest of the boundary.

Checklist (human = needs admin; agent = can draft)

  1. Agent unix user: moved to Agent unix user for delivery sessions.
  2. Bot token (human)
    • Claude is a Write collaborator on defame1297/ansible-homelab-mono, not admin.
    • A new token for delivery sessions, scopes write:repository and write:issue. Separate from the planning token so each can be revoked alone.
  3. Branch protection on main (human)
    • Require PR; 1 approval.
    • Approvals allowlist: humans only (Defame1297).
    • Dismiss stale approvals.
    • Merge allowlist: humans only, Claude excluded.
    • Push allowlist: none.
    • Block on rejected reviews and on an outdated branch.
    • Protected file patterns: .claude/**;.apm/**;apm.yml;apm.lock.yaml;AGENTS.md;CLAUDE.md;docs/agents/**;.gitea/**;.pre-commit-config.yaml
    • ⚠️ Test paths are left out on purpose, departing from ADR-0032: protecting them would block the test author's own commits. The test-path check in item 4 covers them instead.
    • ⚠️ Not certain how Gitea treats a human's PR that touches protected files. Verify with one throwaway PR.
  4. Required status checks (agent drafts, human merges and ticks them required)
    • Ansible Lint Validation / lint_ansible (pull_request): confirm it is required.
    • Flux dry run: new workflow, an offline rendered diff. flux build kustomization --dry-run (or kustomize build) at base and head, diffed, posted as a PR comment and a status.
      • It needs no cluster credential.
      • A live flux diff needs write RBAC, because Kubernetes authorises dry-run requests like real ones, so it is rejected.
    • Test-path check: new workflow; the script runs from main's copy (the same pattern as the Renovate guard in lint_validation.yml).
      • The test author's commit carries a trailer such as Delivery-Stage: test-author.
      • The check fails if any later commit touches the test globs from docs/agents/delivery.md.
  5. Read-only kubeconfig (agent drafts manifests, human applies by merge)
    • A ServiceAccount (e.g. agent-readonly) bound to view.
    • A ClusterRole sealedsecrets-view (get/list/watch on bitnami.com/sealedsecrets) labelled rbac.authorization.k8s.io/aggregate-to-view: "true".
    • A token kubeconfig outside the repo (e.g. /root/.kube/agent-readonly.config); delivery sessions export KUBECONFIG to it.
    • Verify with it: kubectl auth can-i get secrets -A gives no, delete pods gives no, list sealedsecrets -A gives yes.
  6. Gate-label human allowlist (human)
    • Confirm Defame1297 is the only human allowed to set gate labels; it is recorded for docs/agents/delivery.md.
  7. ADR-0032 amendment (agent drafts PR)
    • Accepted risk: sessions run as root until Agent unix user for delivery sessions.
    • Accepted risk: same-repo branches reach repo secrets.
    • Tests dropped from protected file patterns; the test-path check covers them.
    • Flux dry run is an offline render-diff.

Facts to fill in at resolution

Bot username (Claude); kubeconfig path; exact status-check names; protected-file behaviour observed.

## Working checklist (not the resolution) ### Survey findings (2026-11-22) - **Agent sessions run as root on the dev box.** Root can read the real vault password (`/root/ansible/.ansible/vault-pass.txt`), the SSH key (`/root/.ssh/id_ed25519`) and an admin kubeconfig that `KUBECONFIG` already points at (`/root/ansible/.kube/config`). `kubectl auth can-i delete pods -A` and `get secrets -A` both answer `yes`. File contents were not read. - **Pushing branches = reaching repo secrets.** `.gitea/workflows/molecule.yml:10-21` documents that anyone who can push branches can read `ANSIBLE_VAULT_PASSWORD` and `SSH_PRIVATE_KEY` through a workflow. Protected file patterns block the merge, not the run. - **Ansible dry run is post-merge only.** In `provision.yml`, each stage's `--check --diff` runs after merge, non-blocking (`continue-on-error`), in the apply job with the real secrets. Nothing runs before merge. Split out to [Pre-merge Ansible dry run without exposing production credentials](https://git.rkdr.net/Mortis/Holocron/issues/200). - **Lint is a PR check already.** `Ansible Lint Validation / lint_ansible (pull_request)` runs on every PR with no secrets. Whether branch protection *requires* it is unverified. - **No Flux PR check exists.** - `sealed-secrets-backup/sealed-secrets-keys-backup.yaml` is tracked but vault-encrypted (header only checked). It is a Never-tier read target. ### Decisions taken with the owner this session - **Sessions keep running as root for now.** The separate unix user is deferred to [Agent unix user for delivery sessions](https://git.rkdr.net/Mortis/Holocron/issues/201), which blocks nothing. **Accepted risk:** until then, an agent session can read the vault password, the SSH key and the admin kubeconfig. On this box the credential boundary is a guardrail, not a boundary. Partial fix: delivery sessions export `KUBECONFIG` pointing at the read-only kubeconfig, so accidental cluster writes fail. - The bot is the **existing `Claude` Gitea user** (not a new account). - The bot pushes **same-repo branches**. **Accepted risk:** the bot can reach the repo's production secrets through a branch workflow. - Ansible pre-merge dry run: **split to its own grilling ticket**. This ticket covers the Flux dry run and the rest of the boundary. ### Checklist (human = needs admin; agent = can draft) 1. ~~Agent unix user~~: moved to [Agent unix user for delivery sessions](https://git.rkdr.net/Mortis/Holocron/issues/201). 2. **Bot token** (human) - [ ] `Claude` is a Write collaborator on `defame1297/ansible-homelab-mono`, not admin. - [ ] A new token for delivery sessions, scopes `write:repository` and `write:issue`. Separate from the planning token so each can be revoked alone. 3. **Branch protection on `main`** (human) - [ ] Require PR; 1 approval. - [ ] Approvals allowlist: humans only (`Defame1297`). - [ ] Dismiss stale approvals. - [ ] Merge allowlist: humans only, `Claude` excluded. - [ ] Push allowlist: none. - [ ] Block on rejected reviews and on an outdated branch. - [ ] Protected file patterns: `.claude/**;.apm/**;apm.yml;apm.lock.yaml;AGENTS.md;CLAUDE.md;docs/agents/**;.gitea/**;.pre-commit-config.yaml` - ⚠️ Test paths are **left out** on purpose, departing from ADR-0032: protecting them would block the test author's own commits. The test-path check in item 4 covers them instead. - ⚠️ Not certain how Gitea treats a *human's* PR that touches protected files. Verify with one throwaway PR. 4. **Required status checks** (agent drafts, human merges and ticks them required) - [ ] `Ansible Lint Validation / lint_ansible (pull_request)`: confirm it is required. - [ ] **Flux dry run**: new workflow, an **offline** rendered diff. `flux build kustomization --dry-run` (or `kustomize build`) at base and head, diffed, posted as a PR comment and a status. - It needs no cluster credential. - A live `flux diff` needs write RBAC, because Kubernetes authorises dry-run requests like real ones, so it is rejected. - [ ] **Test-path check**: new workflow; the script runs from `main`'s copy (the same pattern as the Renovate guard in `lint_validation.yml`). - The test author's commit carries a trailer such as `Delivery-Stage: test-author`. - The check fails if any later commit touches the test globs from `docs/agents/delivery.md`. 5. **Read-only kubeconfig** (agent drafts manifests, human applies by merge) - [ ] A ServiceAccount (e.g. `agent-readonly`) bound to `view`. - [ ] A ClusterRole `sealedsecrets-view` (`get/list/watch` on `bitnami.com/sealedsecrets`) labelled `rbac.authorization.k8s.io/aggregate-to-view: "true"`. - [ ] A token kubeconfig outside the repo (e.g. `/root/.kube/agent-readonly.config`); delivery sessions export `KUBECONFIG` to it. - [ ] Verify with it: `kubectl auth can-i get secrets -A` gives `no`, `delete pods` gives `no`, `list sealedsecrets -A` gives `yes`. 6. **Gate-label human allowlist** (human) - [ ] Confirm `Defame1297` is the only human allowed to set gate labels; it is recorded for `docs/agents/delivery.md`. 7. **ADR-0032 amendment** (agent drafts PR) - [ ] Accepted risk: sessions run as root until [Agent unix user for delivery sessions](https://git.rkdr.net/Mortis/Holocron/issues/201). - [ ] Accepted risk: same-repo branches reach repo secrets. - [ ] Tests dropped from protected file patterns; the test-path check covers them. - [ ] Flux dry run is an offline render-diff. ### Facts to fill in at resolution Bot username (`Claude`); kubeconfig path; exact status-check names; protected-file behaviour observed.
Author
Owner

Progress (2026-11-22)

Done, merged:

  • Item 5, manifests: defame1297/ansible-homelab-mono PR 928 adds the agent-readonly namespace and ServiceAccount bound to view, plus the sealedsecrets-view role aggregated into view. view already covered the Flux CRDs via flux-view-flux-system. No token is kept in git.
  • Item 4, new checks: defame1297/ansible-homelab-mono PR 929. Both ran green on Gitea.
    • Status-check names: Flux Dry Run / flux_dry_run (pull_request) and Test Paths Frozen / test_paths_frozen (pull_request).
    • The job token can post and update a PR comment (verified: comment 13509 was updated in place).
    • Test globs live in .gitea/test-paths, not in docs/agents/delivery.md; delivery.md should point at that file.
  • Item 7: ADR-0032 amendment. It also moves live kubectl diff and flux diff out of the Read tier, because they are server-side dry runs that need write RBAC.

Left (owner):

  • Item 2: bot token for delivery sessions.
  • Item 3: branch protection on main, with the two new checks required, plus the protected-file-pattern merge behaviour observed.
  • Item 4: confirm lint_ansible is required.
  • Item 5: mint the token, write /root/.kube/agent-readonly.config, and run the three can-i checks.
  • Item 6: gate-label allowlist.

Side finding: running holocron's apm-audit-ci pre-push hook from a linked git worktree with no apm_modules checked out old commits in that worktree and set core.bare=true in the shared .git/config. That broke the main checkout. I reverted it by hand. Pushing from the main checkout works.

## Progress (2026-11-22) **Done, merged:** - **Item 5, manifests:** defame1297/ansible-homelab-mono PR 928 adds the `agent-readonly` namespace and ServiceAccount bound to `view`, plus the `sealedsecrets-view` role aggregated into `view`. `view` already covered the Flux CRDs via `flux-view-flux-system`. No token is kept in git. - **Item 4, new checks:** defame1297/ansible-homelab-mono PR 929. Both ran green on Gitea. - Status-check names: `Flux Dry Run / flux_dry_run (pull_request)` and `Test Paths Frozen / test_paths_frozen (pull_request)`. - The job token **can** post and update a PR comment (verified: comment 13509 was updated in place). - Test globs live in `.gitea/test-paths`, not in `docs/agents/delivery.md`; `delivery.md` should point at that file. - **Item 7:** [ADR-0032 amendment](https://git.rkdr.net/Mortis/Holocron/pulls/202). It also moves live `kubectl diff` and `flux diff` out of the Read tier, because they are server-side dry runs that need write RBAC. **Left (owner):** - [ ] Item 2: bot token for delivery sessions. - [ ] Item 3: branch protection on `main`, with the two new checks required, plus the protected-file-pattern merge behaviour observed. - [ ] Item 4: confirm `lint_ansible` is required. - [ ] Item 5: mint the token, write `/root/.kube/agent-readonly.config`, and run the three `can-i` checks. - [ ] Item 6: gate-label allowlist. **Side finding:** running holocron's `apm-audit-ci` pre-push hook from a linked git worktree with no `apm_modules` checked out old commits in that worktree and set `core.bare=true` in the shared `.git/config`. That broke the main checkout. I reverted it by hand. Pushing from the main checkout works.
Author
Owner

Resolution

The agent side of the boundary is built and merged. The admin-only steps are deferred by the owner to Finish credential boundary admin setup in ansible-homelab-mono, which blocks only Destination test walk-through (Flux).

Decisions (owner, 2026-11-22):

  • The bot is the existing Claude Gitea user, pushing same-repo branches. Accepted risk: a bot branch can reach repo secrets through a pull_request workflow.
  • Sessions keep running as root for now. Accepted risk; the fix is Agent unix user for delivery sessions, which blocks nothing.
  • Test paths are not protected file patterns. A CI check guards them instead.
  • The Flux PR dry run is an offline render diff. Live kubectl diff and flux diff are not Read tier, because they need write RBAC.
  • The Ansible pre-merge dry run is split to Pre-merge Ansible dry run without exposing production credentials.
  • All of the above is recorded in ADR-0032 (holocron PR 202, merged).

Facts later tickets depend on:

  • Bot username: Claude.
  • Gate-label human allowlist: Defame1297.
  • Read-only identity:
    • ServiceAccount agent-readonly in namespace agent-readonly, bound to view, with sealedsecrets-view aggregated into view (ansible-homelab-mono PR 928).
    • Kubeconfig path: /root/.kube/agent-readonly.config, outside the repo. It is not created yet; see the deferred ticket.
  • Required status-check names (ansible-homelab-mono PR 929 adds the last two):
    • Ansible Lint Validation / lint_ansible (pull_request)
    • Flux Dry Run / flux_dry_run (pull_request)
    • Test Paths Frozen / test_paths_frozen (pull_request)
  • Test globs: .gitea/test-paths, read from main. docs/agents/delivery.md points at this file rather than restating the globs.
  • Test-author trailer: Delivery-Stage: test-author.
  • The Flux dry run posts one PR comment as gitea-actions and updates it in place (verified).
## Resolution The agent side of the boundary is built and merged. The admin-only steps are deferred by the owner to [Finish credential boundary admin setup in ansible-homelab-mono](https://git.rkdr.net/Mortis/Holocron/issues/203), which blocks only [Destination test walk-through (Flux)](https://git.rkdr.net/Mortis/Holocron/issues/195). **Decisions (owner, 2026-11-22):** - The bot is the existing `Claude` Gitea user, pushing same-repo branches. Accepted risk: a bot branch can reach repo secrets through a `pull_request` workflow. - Sessions keep running as root for now. Accepted risk; the fix is [Agent unix user for delivery sessions](https://git.rkdr.net/Mortis/Holocron/issues/201), which blocks nothing. - Test paths are **not** protected file patterns. A CI check guards them instead. - The Flux PR dry run is an offline render diff. Live `kubectl diff` and `flux diff` are not Read tier, because they need write RBAC. - The Ansible pre-merge dry run is split to [Pre-merge Ansible dry run without exposing production credentials](https://git.rkdr.net/Mortis/Holocron/issues/200). - All of the above is recorded in ADR-0032 (holocron PR 202, merged). **Facts later tickets depend on:** - Bot username: `Claude`. - Gate-label human allowlist: `Defame1297`. - Read-only identity: - ServiceAccount `agent-readonly` in namespace `agent-readonly`, bound to `view`, with `sealedsecrets-view` aggregated into `view` (ansible-homelab-mono PR 928). - Kubeconfig path: `/root/.kube/agent-readonly.config`, outside the repo. It is not created yet; see the deferred ticket. - Required status-check names (ansible-homelab-mono PR 929 adds the last two): - `Ansible Lint Validation / lint_ansible (pull_request)` - `Flux Dry Run / flux_dry_run (pull_request)` - `Test Paths Frozen / test_paths_frozen (pull_request)` - Test globs: `.gitea/test-paths`, read from `main`. `docs/agents/delivery.md` points at this file rather than restating the globs. - Test-author trailer: `Delivery-Stage: test-author`. - The Flux dry run posts one PR comment as `gitea-actions` and updates it in place (verified).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: Mortis/Holocron#184