Repository navigation
Description
Problem or Motivation
A change to dan-petty/homelab reaches the hosts by make <target> ANSIBLE_ARGS="--limit <host>". Nobody sees before the run which tasks change on which host, or that a change restarts k3s. Example of 2026-11-12: dan-petty/homelab#19 (kubelet memory reservations) is merged and not applied. The owner ran make k3s ANSIBLE_ARGS="--limit hawk.lan --check --diff": ok=9 changed=2, the agent config template (no diff output, because it holds the join token) and the k3s-agent restart. Only a person reading the task names sees that the apply restarts k3s. Agents may apply plays (owner decision 2026-11-12), but only after a plan of the same commit.
Proposed Solution & Architectural Design
devops infra plan <repo> <playbook> [--limit] [--tags] [--ref] (design sections 5 and 6 in tracker #5120).
- Export the commit with
git archive(defaultorigin/<default branch>;--reftakes a branch or a PR head thatoriginholds) into the project folder of an ansible-runner private data folder under.data/infra/<owner>/<name>/plans/<id>/(mode 0700). Never use the working tree. - Run
ansible-runner run <pd> -p <playbook> --cmdline "--check --diff --limit '<limit>:!offline'"throughrun_subprocess(isolate_env=True;ANSIBLE_CONFIGof the export; the key ofdevops sshas the extra variableansible_ssh_private_key_file). Install the pinned collections ofcollections/requirements.ymlfirst, when the repo has one. - Read
artifacts/<ident>/job_events/*.jsoninto Pydantic models. For each host: changed tasks (task_path, name), tasks that check mode skipped (unchecked), changes with the diff hidden (diff: false,no_log), and disruptive classes from the events:reboot(ansible.builtin.reboot),service-restart:<unit>(a changedsystemd,systemd_serviceorservicetask with staterestarted,reloadedorstopped, for any unit that the host variabledevops_infra_nondisruptive_unitsdoes not list; the safe side is the default),drain(kubernetes.core.k8s_drain). - Save
plan.json: repo, commit, ref, playbook, limit, tags, ansible-core version, inventory hash, the per-host summary. The plan id is the SHA-256 of its canonical JSON without the time. Print a table and the id;--format jsonprints the model. - Agent level
planor higher.--dry-runmakes zero requests and prints the would-be commands.
Target Subsystem
OpenTofu / Infrastructure as Code
Existing Tool Considered
ansible-runner gives the run folder, the AWX event schema and the timeouts. A probe on 2026-11-12 (ansible-runner 2.4.3, ansible-core 2.21.4, Python 3.14.10) showed runner_on_ok with res.changed and res.diff, runner_on_skipped for command in check mode, and handlers that run in check mode. Building the same on the ansible.posix.jsonl callback costs about 1.5M tokens and 3 hours more. Cost of this item: about 3.5M tokens to build, 0.5M a quarter to keep, 5 hours.
Acceptance Criteria
- Tests with recorded runner event files: a changed template with a diff, a changed template with the diff hidden, a skipped
command, a notified restart handler, a reboot task, a failed task (the plan is marked failed). - A test: the same events give the same plan id; a different commit or limit gives another id.
- A test: a host in
offlineis never in the limit. - A test: an agent caller on a repo at level
noneis refused before any process starts. - A test:
--dry-runstarts no process. - Live run on
origin/mainof dan-petty/homelab (dan-petty/homelab#19 merged, not applied), recorded in a PR comment:uv run devops infra plan dan-petty/homelab ansible/playbooks/03_k3s.yaml --limit hawk.lanshows the same 2 changes as the owner's check run: onhawkthe agent config template changed with the diff hidden andservice-restart:k3s-agent, and no change on other hosts. No host changes (checkuptimeand thek3s-agentstart time onhawkbefore and after).
Activity
dan-petty commentedon Nov 12, 2026
Both belong to the devops infra command group; #5120 is the umbrella and the candidate is the specific plan sub-command.devops-cli-service commentedon Nov 12, 2026
Released in v0.123.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.123.0
devops-cli-service commentedon Nov 12, 2026
Live since 2026-11-12 20:34 UTC