Repository navigation
Description
Problem or Motivation
The owner decided on 2026-11-12 ("Agents apply all", then "agent use approval of the infra repos should be configurable, and I want homelab specifically to be full access to agents because it is dedicated to developing, troubleshooting, and validating project features and capabilities"). Today AGENTS.md says that only a person changes hosts, so agents hand the owner make commands, for example make k3s ANSIBLE_ARGS="--limit hawk.lan" for dan-petty/homelab#19, which restarts k3s on the host. Agents need one sanctioned path that applies a reviewed plan with guards, and the approval must be a setting of each infra repo, not one global rule.
Proposed Solution & Architectural Design
devops infra apply <repo> --plan <id> [--auto-approve] (design sections 4, 7 and 11 in tracker #5120).
- Access level (
infra/access.py: require_access):none(an agent reaches no host),plan(status--ping, plan, drift),safe(also apply a plan with no disruptive class and no unchecked task;node uncordon),full(also any plan and the node commands, one node at a time). A person may do all. The caller is an agent whendetect_agentorAI_AGENTnames a tool, through MCP, or in a cluster Job. - Guards at every level, for every caller: the plan record exists, its hash matches, it is younger than
infra.plan_max_age_hours, and its playbook, limit and tags are the ones given; the commit is onorigin(an agent: a default-branch commit, or atfullthe head of an open PR of the infra repo); an agent apply is refused when the effective config turns host key checks off; health before (every in-service node Ready, no memory, disk or PID pressure, no firingseverity="critical"alert whenprometheus.urlis set); hosts with no disruptive class run together; each disruptive host runs alone in plan order: record its cordon state,kubectl drain(no--forceby default), a fresh check of that host that must match the plan, the run with--limit <host>, wait for the unit and Ready, GPU allocatable equal to its value before, uncordon only when the node was schedulable before, health again; a changed task that the plan did not list stops the run; the first failure stops the run and leaves the node cordoned. - Audit and telemetry:
record_audit_event("infra.apply", ...)with caller kind and tool, level, repo, commit, plan id, hosts with result and disruptive classes, runner ident; instrumentsdevops_cli_infra_runs_total{repo,command,result}inINSTRUMENTS. - Secrets and hardware stay with the owner. devops passes only the
devops sshkey. A person changes the level (AGENTS.md rule 12 and the refusal of feat(infra): onboard an Ansible infra repo #5121). - Claude Code permission rule (owner step). The auto-mode classifier refused
make k3s ANSIBLE_ARGS="--limit hawk.lan"from an agent on 2026-11-12, because no allow rule covered it. The project.claude/settings.jsonallowsBash(uv run devops *), and a matching allow rule resolves before the classifier. The owner step: keep that rule. A rule matches the whole command, so a compound shell line (an assignment,;,&&,|) falls to the classifier: agents runuv run devops infra ...as one plain command. If auto mode drops the rule (the docs say that it drops package-manager run-command rules, and do not say whetheruv runis one), the owner adds anautoMode.allowentry in~/.claude/settings.json. The real control is the access level in the CLI. The docs ofapplysay all of this. - Policy text, written as merged in this PR: the "Only a person" paragraph of AGENTS.md and a new
## Infra Repossection of SECURITY.md, in the exact words of design section 11 (the tracker quotes them). SECURITY.md item 3 listsansible-runner. --dry-runmakes zero requests and prints the would-be commands in order.
Target Subsystem
OpenTofu / Infrastructure as Code
Existing Tool Considered
ansible-runner runs the plays; kubectl drain, uncordon and wait do the node steps; the existing Prometheus client reads alerts; record_audit_event writes the record. Considered and not chosen: kured (reboots only, no plan), AWX and Semaphore (a second control plane and secret store). Cost: about 4.5M tokens to build, 0.6M a quarter to keep, 6 hours.
Acceptance Criteria
- Tests with recorded events and a fake kubectl: refusal for each level and caller kind; refusal for a changed hash, an old plan, another limit, a commit that
origindoes not hold, host key checks off for an agent; one disruptive host at a time in plan order; a node that was cordoned before stays cordoned; a fresh check that differs stops the run before the run of that host; a health failure after a host stops the run and leaves it cordoned; an unplanned changed task stops the run. - A test: the audit record holds every field of the design and no secret.
- A test:
--dry-runstarts no process. - AGENTS.md and SECURITY.md hold the text of design section 11.
- Live run at level
fullby an agent, recorded in a PR comment with the audit records. dan-petty/homelab#19 (kubelet memory reservation, merged, not applied): plan and applyansible/playbooks/03_k3s.yamlonhawk, thencondor,geminiandhog, one host for each plan and apply. Each apply drains the host, restarts k3s, waits for Ready and shows allocatable memory below capacity.hawkstays cordoned, because it was cordoned before; the other 3 are uncordoned. Whilehog(the control plane) restarts, the API is down for a short time; the waits retry through the gap and the run ends green. - Live run: dan-petty/homelab#20 (crash capture, merged, not applied): plan and apply
ansible/playbooks/13_crash_capture.yamlonhawk. The reboot that kdump needs is feat(infra): add node drain, uncordon, restart and reboot #5128. - The docs of
applyname the owner step (keepBash(uv run devops *)in the allow list), say that a compound shell line falls to the classifier, and say that the access level in the CLI is the real control. The live agent run shows that auto mode letuv run devops infra applystart; if it did not, the PR body gives theautoMode.allowfallback.
Dependencies
#5124; dan-petty/homelab#1 (host key checks on) for the agent run.
Activity
dan-petty commentedon Nov 12, 2026
5120 is the umbrella for all devops infra commands; this candidate is the apply sub-command split from it.feat(infra): plan a playbook of an infra repo in check mode (#5196)
devops-cli-service commentedon Nov 12, 2026
Released in v0.124.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.124.0
devops-cli-service commentedon Nov 12, 2026
Live since 2026-11-12 23:12 UTC
feat(infra): Open CloudNativePG window before drain (#6976)