Skip to content

feat(infra): onboard an Ansible infra repo #5121

Closed

Description

@dan-petty

Problem or Motivation

The owner asked on 2026-11-12 for native devops commands that manage an infrastructure environment kept in a git repo, first dan-petty/homelab. That repo holds an Ansible inventory, playbooks and roles. Today a person runs make targets of that repo by hand, and agents give the owner make commands. Every later devops infra command (status, plan, apply, drift, node) needs to know which repos are infra repos, where they are, how their Ansible content is laid out, and the agent access level of each. Nothing records this now. The owner also asked (2026-11-12) to use the homelab repo to validate the onboarding of an infra repo.

Proposed Solution & Architectural Design

Design: .data/agent/scratch/infra-repo/DESIGN.md (sections 1, 3, 4, 5) of the filing session; the tracker #5120 holds the summary.

  1. Settings. A new infra section: plan_max_age_hours, drain_timeout_seconds, node_ready_timeout_seconds, and repos, a list of entries with repo (a RepoRef), path (default <repos.base_dir>/<owner>/<name>), kind (ansible), kube_context, ssh_key_prefix (default ansible), agent_access (none, plan, safe or full; default none), purpose (free text) and k8s_dir (default none). The field description of agent_access says what each level lets an agent do.
  2. Tool pin. A [python.ansible] entry in src/devops_cli/tools_lock/tools.lock with hashed requirements for ansible-core and ansible-runner (entry points ansible-runner, ansible-playbook, ansible, ansible-inventory, ansible-config, ansible-galaxy). devops install-tools installs it. Not a pyproject.toml dependency: ansible-core is GPL-3.0-or-later and runs only as a separate process.
  3. devops infra onboard <repo> (a GitHub name or a local path). It reads only the local checkout and local tool output: ansible-config dump --format json (inventory and roles path, host key settings), ansible-inventory --list (groups and hosts), the playbook files, collections/requirements.yml, and the devops_infra_ inventory variables through the debug action plugin (no SSH). It prints one row for each check, with a state, a reason and a step, as devops roadmap onboard does (src/devops_cli/roadmap/onboard.py): tool environment present, devops ssh key of the prefix present, each in-service host in ~/.ssh/known_hosts, host key checks on, kube context present, CI workflow present, offline group present, collections pinned, tasks with check_mode: false (listed, because they run during a plan), per-host Makefile targets that devops infra node replaces.
  4. --confirm writes the settings entry with save_settings, at level none unless --agent-access <level> is given. An agent caller (detect_agent, AI_AGENT, MCP) cannot give a level above none: the command refuses and names the setting. --dry-run makes zero requests and lists the commands that a real run starts.
  5. A new command group devops infra, with onboard as its first command. Docs: the generated command reference and README settings.

Target Subsystem

OpenTofu / Infrastructure as Code

Existing Tool Considered

Ansible's own tools give the facts: ansible-config dump --format json and ansible-inventory --list. ansible-runner (Apache-2.0, 2.4.3) is the engine of the later commands, chosen over ansible-navigator, AWX (no release since 2024-07-02) and Semaphore (a second stateful service and secret store); see the tracker. The onboarding rows are glue around those tools. Cost: about 2.5M tokens to build, 0.3M tokens a quarter to keep, 4 hours.

Acceptance Criteria

  • Tests with a fixture repo that copies the shape of dan-petty/homelab (groups k3s_cluster, k3s_server, k3s_agent, gpu_nodes, debian_nodes, offline; host_vars; playbooks 00-12, site.yaml, health_check.yaml) with example.com hosts and RFC 5737 addresses: every row of the report, for a complete repo and for a repo that lacks each item.
  • A test: a repo entry with no agent_access reads as none.
  • A test: an agent caller with --agent-access full --confirm is refused, and no file changes.
  • A test: --dry-run starts no process and sends no request.
  • devops install-tools installs the pinned [python.ansible] environment, and ansible-runner --version runs from it.
  • Live run on dan-petty/homelab from an empty config: DEVOPS_CLI_CONFIG=<empty file> uv run devops infra onboard dan-petty/homelab, then the same with --confirm. The report and the resulting settings entry (level none) are in a PR comment, not in a committed file. The report shows at least: host key checks off (dan-petty/homelab#1), no CI (dan-petty/homelab#8), no collections/requirements.yml, and the per-host Makefile targets.
  • The PR body gives the owner's step to set homelab to full: uv run devops infra onboard dan-petty/homelab --agent-access full --confirm.

Dependencies

None. This is the first slice of #5120.

Activity

  1. added
    source/agent
    type/feature
    scope/infra
    status/new
    value/high
    effort/medium
    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. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 12, 2026
  5. removed
    status/in-review
    owner/agent
    on Nov 12, 2026
  6. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor
  7. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-12 17:54 UTC

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/mediumpriority/p2-mediumscope/infrasource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions