Skip to content

feat(infra): manage infra repos with devops infra #5120

Open
22 of 23 issues completed
Open

Description

@dan-petty

Update 2026-11-26 (infra move): tools.lock is gone and the environment move is done.

ansible-runner and ansible-core come from the devtools image, not from tools.lock (#6555). Argo CD reads the environment from dan-petty/homelab since 2026-11-23. Step 17, which deletes the devops-cli copy, is #7290. The listed items are closed, except #5134 (its step 17 is #7290). Before you close this tracker, check the scope comments (an apply result line, more status columns) and the last criterion.


Problem or Motivation

The owner, 2026-11-12:

  • "I also want to have native devops cli functionality to manage an infrastructure environment stored in a git repo, mine being https://github.com/dan-petty/homelab"
  • "Agents apply all" (agents may apply any play after a plan, including drain, k3s restart and reboot of one node at a time; only secrets and hardware stay with the owner)
  • "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"
  • "you should also use the homelab repo to validate the devops cli infra repo onboarding functionality"
  • "once infra environment repo management is supported, we can move homelab configuration artifacts to that repo and update argocd config"
  • "build the functionality into the devops cli infra management feature and let me know when that is ready"

Today a person runs make targets of dan-petty/homelab, and AGENTS.md says that only a person changes hosts. Live example: a GPU node (<gpu-node>) hung on 2026-11-10 and came back with 16 GiB. dan-petty/homelab#19 (kubelet memory reservation) and dan-petty/homelab#20 (crash capture) are merged and not applied; the Claude Code auto-mode classifier refused make k3s ANSIBLE_ARGS="--limit <gpu-node>" from an agent.

Proposed Solution & Architectural Design

A new command group devops infra for infra repos: git repositories with an Ansible inventory, playbooks and roles. dan-petty/homelab is the first and the validation repo.

Engine: the ansible-runner CLI (Apache-2.0, 2.4.3), run through run_subprocess, from the devtools image (ansible-core + ansible-runner). It gives the AWX job events, a run folder for each run, timeouts, and a remote mode for later. Not its Python API: that starts ansible-playbook inside the devops process and copies os.environ past the subprocess guards. ansible-core is GPL-3.0-or-later and stays in its own process.

Contract: settings infra.repos[] (repo, path, kube_context, ssh_key_prefix, agent_access). The repo gives the rest with standard Ansible: ansible.cfg, the inventory, the offline group, collections/requirements.yml, serial, and inventory variables devops_infra_node_service, devops_infra_nondisruptive_units, devops_infra_node_name (read with the debug action plugin, no SSH). No new manifest file. The repo gives its Kubernetes environment tree as the profile fact kubernetes.dir in .devops/project.toml. infra.repos[] has no k8s_dir key, because InfraRepoConfig forbids extra keys.

Agent access level of each repo (infra.repos[].agent_access): none (default; an agent reaches no host), plan (status --ping, plan, drift), safe (also apply a plan with no disruptive task and no unchecked task; uncordon), full (also any plan and the node commands, one node at a time). Only a person sets it. dan-petty/homelab is full.

Command Does
devops infra onboard <repo> Detects and checks the repo; --confirm records it (level none unless a person gives another)
devops infra status <repo> Inventory hosts joined with node state from the Kubernetes API; --ping adds SSH and pending reboot
devops infra plan <repo> <playbook> Check mode with diff on an exported commit; per host: changed, unchecked, diff hidden, disruptive (reboot, service-restart:<unit>, drain); a saved plan with a hash
devops infra apply <repo> --plan <id> Applies a saved plan with the guards below
devops infra drift <repo> Plan of the default branch on every in-service host; gauge; one issue in the infra repo
devops infra node drain|uncordon|restart|reboot <repo> <host>... The node life cycle with health gates; replaces the per-host Makefile targets

Guards at every level, for every caller: a plan of the same commit, playbook, limit and tags, not older than infra.plan_max_age_hours; the commit is on origin; host key checks on for an agent; health before; one disruptive node at a time (drain, fresh check equal to the plan, run, Ready, GPU count, uncordon only if it was schedulable, health); an unplanned change stops the run; the first failure stops and leaves the node cordoned; an audit record (record_audit_event: caller, level, repo, commit, plan hash, hosts, result); metrics devops_cli_infra_runs_total, devops_cli_infra_drift_hosts; --dry-run makes zero requests. Secrets and hardware stay with the owner: only the devops ssh key goes to Ansible.

Claude Code permission rule (owner step): the project .claude/settings.json allows Bash(uv run devops *), and a matching allow rule resolves before the auto-mode classifier, so uv run devops infra ... as one plain command needs no other rule. Keep that rule. A compound shell line (an assignment, ;, &&, |) falls to the classifier. If auto mode drops the rule (the docs say that it drops package-manager run-command rules, and do not name uv run), the fallback is an autoMode.allow entry in ~/.claude/settings.json. The access level in the CLI stays the real control.

Policy text that the apply item writes (as merged). AGENTS.md, today: "Only a person merges pull requests (release-merge.yml merges the release pull request), records verdicts, plans milestones and changes secrets, repository settings and hosts." After: "Only a person merges pull requests (release-merge.yml merges the release pull request), records verdicts, plans milestones, changes secrets, repository settings and hardware, and sets the agent access level of an infra repo. Agents change a host only with devops infra, and only as far as the access level of its infra repo allows (SECURITY.md). The homelab repo is at full, because it exists to develop, troubleshoot and validate the features of the project." SECURITY.md gets a section ## Infra Repos with the levels, the guards, "Secrets and hardware stay with the owner at every level", and "The level stops an agent error; it is not a security boundary, because an agent with a shell can run ansible-playbook. So an agent changes a host only with devops infra, never with ansible-playbook, kubectl drain, make or a reboot over SSH."

Phases and build order

  1. Workstation (first): feat(infra): onboard an Ansible infra repo #5121 onboard (first slice), feat(infra): show the hosts of an infra repo with node state #5123 status, feat(infra): plan a playbook of an infra repo in check mode #5124 plan, feat(infra): apply a saved plan one node at a time #5125 apply + access levels + policy text, feat(infra): report drift of an infra repo #5127 drift, feat(infra): add node drain, uncordon, restart and reboot #5128 node. homelab: dan-petty/homelab#21 node facts, dan-petty/homelab#8 CI lint, dan-petty/homelab#1 host keys, dan-petty/homelab#22 declarative content only (supersedes dan-petty/homelab#9).
  2. Environment move (after phase 1). The comment of 2026-11-13 on this issue gives the corrected plan in 18 steps, with the check, the rollback and the owner steps. Order: refactor(k8s): split the product dashboards and rules in place #5292 product split in place (plan step 2); docs(k8s): move the product README sections to docs/ #5293 README product sections to docs/ (step 3); refactor(k8s): read the environment tree from the infra repo #5131 PR 1, readers take the environment tree from the profile fact kubernetes.dir and resolve a source by its repoURL (step 4; its fixture PR comes before step 17); fix(k8s): deploy-stack fetches a private Application repo #5294 deploy-stack fetches a private Application repo (step 5); release vX with steps 2-5 (step 6); feat(argocd): read the environment from the homelab repo #5134 step 1, the owner adds the repository credential and installs the App (step 7); feat(argocd): read the environment from the homelab repo #5134 step 2 with feat(security): refuse a diff that names the configured domain #5295, the private-domain guard (step 8); dan-petty/homelab#23 homelab receives the environment files and their CI (step 9); feat(argocd): read the environment from the homelab repo #5134 Argo CD cutover, supersedes feat(k8s): Read homelab config from in-cluster Gitea, drop overrides #1291 (steps 10-15); feat(k8s): run the environment checks in homelab CI #5296 homelab environment checks (step 16); feat(argocd): read the environment from the homelab repo #5134 step 6 deletes the environment files from devops-cli (step 17); build(k8s): pin the product base to a release tag #5135 product source pinned to a release tag after the cutover (step 18).
  3. Cluster (later, ADR 0021): feat(infra): run drift in the cluster and plan infra PRs #5129 drift CronWorkflow and PR plan comments, feat(infra): apply a merged infra PR in a step job #5130 apply a merged infra PR in a step job.

Live validation on homelab: onboarding from an empty config (#5121); plan of 03_k3s.yaml on <gpu-node> shows the 2 changes of the owner's check run (#5124); apply dan-petty/homelab#19 on each of the 4 nodes one at a time and 13_crash_capture.yaml on <gpu-node> (#5125); reboot <gpu-node> so kdump reserves memory (#5128).

Target Subsystem

OpenTofu / Infrastructure as Code

Existing Tool Considered

ansible-runner (chosen). Rejected: ansible-playbook with the ansible.posix.jsonl callback (we would build the run folder, events and timeouts: about 1.5M tokens and 3 hours more); ansible-navigator (a TUI for execution-environment containers); AWX (a second control plane, no release since 2024-07-02); Semaphore (a second stateful service and secret store); kured and system-upgrade-controller (reboot or k3s upgrade only; revisit later); an own SSH executor (about 15M tokens). Total build of all items about 40M tokens and 58 hours.

Acceptance Criteria

  • Every sub-issue is closed.
  • An agent applies a plan on dan-petty/homelab at level full with devops infra apply, with no make command and no raw reboot.

Dependencies

#3767 (devops pr create and devops pr ready for a repo with no OpenSpec and no CI; every homelab item needs it); dan-petty/homelab#1 (host key checks, needed for agent applies).

Alternatives check of 2026-11-27: in-use.
The repository already uses this tool.
Tool: ansible/ansible-runner (https://github.com/ansible/ansible-runner), NOASSERTION, last activity 2026-11-12, maintained.
Reason: Searches and repository facts confirm ansible-runner is the maintained Ansible execution engine the issue already names; it runs playbooks with run folders, job events and timeouts, but onboarding, plan/apply guards, drift and node life cycle stay custom.

Covers:

  • Runs a playbook in its own run folder with artifacts
  • Emits job events, timeouts and a remote execution mode
  • Keeps ansible-core in its own process, outside devops environment guards

Lacks:

  • No inventory join with node state or SSH ping status
  • No check-mode plan hash, diff or disruptive-task classification
  • No agent access levels, drift gauge, audit record or node drain/reboot gates

Sub-issues

Sub-issues

22 of 23 Issues completed
Loading 23 sub-issues

Activity

  1. added
    source/agent
    type/feature
    scope/infra
    status/new
    value/high
    effort/high
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 12, 2026
  4. 8 remaining items

  5. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    Corrected plan for phase 2 (2026-11-13)

    The owner approved phase 2 of the corrected plan and accepted the 11 owner-step recommendations on 2026-11-13. The plan was checked against devops-cli origin/main 7a158c4c3, homelab origin/main 19f0457 and the live cluster, read only. At the cutover, the plan keeps the behaviour of today: Application devops reads devops-cli k8s/devops on main, and the product ref of Application prometheus reads main. The release-tag pin of #5135 comes after the cutover. Public evidence holds exit codes and counts only, never diff output or Application YAML.

    Order of work

    Step Repository Item Who
    1 devops-cli, homelab Issue text: this comment, the bodies of #5120, #5131, #5134, #5135 and dan-petty/homelab#23, and the new sub-issues #5292 to #5296 agent (done)
    2 devops-cli #5292 product split in place: dashboards and alert rules agent; a person merges
    3 devops-cli #5293 README product sections to docs/ agent; a person merges
    4 devops-cli #5131 PR 1 (environment root from kubernetes.dir, foreign-source support) before S; the fixture PR before step 17 agent; a person merges
    5 devops-cli #5294 deploy-stack fetch of a private Application repo agent; a person merges
    6 devops-cli Release vX with steps 2 to 5 release-please and release-merge.yml
    7 cluster and GitHub settings #5134 step 1: repository credential and App installations owner
    8 devops-cli #5134 step 2 (sourceRepos, runbook) with #5295 private-domain guard agent; a person merges
    9 homelab dan-petty/homelab#23: copy at devops-cli commit S, and CI agent; a person merges
    10 devops-cli and cluster #5134 drift check, baseline and pre-checks agent
    11 cluster #5134 steps 3 and 4: the switch agent, after the owner says go
    12 devops-cli and cluster #5134 freeze check of the old environment paths, and soak (1 day and 1 release) agent; a person merges
    13 homelab #5134 step 5a: prune on in 2 PRs, leaves first agent; a person merges
    14 homelab #5134 step 5b: the live patch lists into the Application files agent; a person merges
    15 devops-cli #5134 step 5c: delete the #1290 override path agent; a person merges
    16 homelab #5296 environment checks in homelab CI (advisory) agent; a person merges
    17 devops-cli #5134 step 6: delete the environment files (after 7 days, the #5131 fixture PR and step 16) agent; a person merges
    18 homelab and devops-cli #5135 release-tag pin in one Renovate group agent; a person merges

    Owner steps (decided 2026-11-13)

    1. Repository credential. The existing GitHub App devops-cli-argocd (Contents: read) is installed on homelab. The owner creates the Argo CD repository credential object. No deploy key. Before step 11.
    2. Deploy-status App. The owner installs devops-cli-argocd (Deployments: write) on homelab before step 11.
    3. homelab main. homelab is the development environment. It keeps the branch and pull request conventions and gets a .pre-commit-config.yaml with the pre-commit-hooks hook no-commit-to-branch (branch main). It gets no branch protection, no ruleset, no required check and no other gate that blocks or delays work. The step 16 environment checks are advisory: they report on each pull request and never block a merge or an apply.
    4. Actions minutes. Path filters on each homelab workflow. Renovate makes the version bumps, so no workflow runs at each devops-cli release. Measure the minutes after one month.
    5. History. Copy without history, and record S in the dan-petty/homelab#23 PR body. git log S -- <path> in devops-cli gives the old history.
    6. Legacy tunnel manifest. The Argo CD copy (moved from devops-cli k8s/cloudflared in the Tunnel group) is the one definition of the tunnel. dan-petty/homelab#23 deletes k8s/manifests/cloudflared.yaml and changes the Makefile target tunnel: it only creates or rotates the cloudflared-tunnel-token Secret from $CLOUDFLARE_TUNNEL_TOKEN and restarts the Deployment. It no longer applies a manifest. The token stays out of git.
    7. Renovate App. The owner installs the Renovate App on homelab before the build(k8s): pin the product base to a release tag #5135 bumps start.
    8. build(k8s): pin the product base to a release tag #5135 pin policy. After the cutover, one Renovate group pins the devops source, the prometheus product ref and the dashboards ref to a release tag, together with the image tags. Until then, everything tracks main.
    9. Go for the switch. Step 11 waits for the owner's go. The agent asks when steps 1 to 10 pass their checks.
    10. Merges. The owner merges the PRs in both repositories. The release PR merges through release-merge.yml.
    11. Gitea pull-mirror credential. Later, outside this cutover.

    New sub-issues of #5120

    The bodies of #5120, #5131, #5134, #5135 and dan-petty/homelab#23 now give this order, the checks and the dependencies.

  6. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor

    Scope from the spec split (2026-11-13)

    The Kubernetes spec (PR #5492) loses its node table (Table 1) in the split (owner directions of 2026-11-13), and the Kubernetes guideline links devops infra status for the node facts. Please add these columns to devops infra status, from the node object that the command already reads:

    • CPU capacity and allocatable CPU;
    • the containerd version (status.nodeInfo.containerRuntimeVersion);
    • the GPU product (label nvidia.com/gpu.product);
    • the tier labels of the Ollama placement (nvidia.com/gpu.total-vram-gib, nvidia.com/gpu.architecture);
    • the runtime handlers (status.runtimeHandlers), so the gVisor nodes show.

    The command shows the GPU count today, and #5123 is closed, so this is new scope for this tracker.

  7. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The issue already names ansible-runner as the chosen execution engine for the new devops infra command group, and ansible-runner (Apache-2.0, v2.4.3, active) covers that engine part — running Ansible playbooks with job events, a per-run folder, timeouts and a remote mode. But it does not cover the issue's broader need: onboarding infra repos, status joined with Kubernetes node state, plan hashing and per-host disruptive detection, apply guards (one disruptive node at a time, health gates), drift, node lifecycle (drain/uncordon/restart/reboot) and agent access levels, which the issue builds itself in the devops CLI.

    The repository already uses this tool.

    Tool: ansible/ansible-runner (https://github.com/ansible/ansible-runner)

    • License: NOASSERTION
    • Last activity: 2026-11-12
    • Maintained: yes

    Covers:

    • Ansible playbook execution engine: run playbooks against an inventory
    • Job events, a run folder per run, timeouts, and a remote mode

    Lacks:

    • onboarding of git-based infra repos and agent access levels
    • status joining inventory with Kubernetes node state
    • plan hashing and per-host disruptive/diff detection
    • apply guards (one disruptive node at a time, health gates, audit, metrics)
    • drift detection and node lifecycle (drain, uncordon, restart, reboot)

    Tools considered:

    Searches run:

    • ansible-runner run Ansible playbooks job events run directory timeouts CLI, results: 5

    Sources:

    Checked on 2026-11-16. A person decides what this means for the item. The check changes no label and closes no issue.

  8. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor

    Infra repos plan of 2026-11-21 (ADR 0032, #6674): dan-petty/infra holds the shared templates (the service repository GitOps template and tenant chart, the External Secrets Operator templates, the Valkey base, Kustomize components, values templates of the platform stacks, the Ansible collection, the OpenTofu modules, the Renovate presets and a reusable check workflow). homelab holds the instances, the services entries and the sensitive values, and later the definitions of the environment Secret rows (dan-petty/homelab#96, #6685). devops-cli keeps its own deployment (k8s/devops) and the product code. The items fit #5134 as approved: each homelab switch waits for plan step 12 and homelab#38.

  9. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: in-use, tool https://github.com/ansible/ansible-runner. A person decides what the new result means for the item.

    Searches (7)

    Tools considered:

    Searches run:

    • ansible-runner CLI run playbooks events run folder timeouts, results: 5
    • self-hosted Ansible GitOps tool plan apply drift detection audit access control, results: 5
    • Semaphore UI ansible playbook git repository approval audit log, results: 5
    • ansible-runner pypi package ansible playbook execution engine, results: 5
    • AWX ansible controller open source, results: 5
    • Ansible playbook check mode diff plan apply automation tool github, results: 5
    • ansible-runner documentation readthedocs, results: 5

    Sources:

  10. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: in-use, tool https://pypi.org/project/ansible-runner. A person decides what the new result means for the item.

    Searches (6)

    Tools considered:

    Searches run:

    • open source tool manage Ansible infrastructure git repository inventory playbooks web UI, results: 5
    • ansible-runner CLI run playbooks job events artifact directory, results: 5
    • ansible-runner github repository, results: 5
    • ansible-navigator vs ansible-runner difference, results: 5
    • "ansible-runner" python package PyPI, results: 5
    • Semaphore UI Ansible alternative AWX maintained, results: 5

    Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/highpriority/p2-mediumscope/infrasource/agentstatus/newtype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions