Skip to content

refactor(ansible): consolidate duplicated backend migration sequence into a shared tasks file #10046

Closed

Description

@mrveiss

Discovered during

Self-review of PR #10039 (#10001/#10026) — composability pass.

Problem

The strict migration sequence (mode probe → local-PG check → pg_dumpall backup → python -m migrations.baseline → alembic -c migrations/alembic.ini upgrade head) now exists twice, near-identically (~70 lines each):

  • autobot-slm-backend/ansible/setup-user-backend.yml (post_tasks)
  • autobot-slm-backend/ansible/playbooks/update-all-nodes.yml (Play 2)

Differences are only parameterization: {{ backend_code_dir }}/{{ backend_user }} vs hardcoded /opt/autobot/autobot-backend/autobot, and task-name prefixes. Two copies will drift the first time one is touched (e.g. the #10045 backup fix would have to land twice).

Fix

  1. Extract to autobot-slm-backend/ansible/roles/backend/tasks/migrate.yml (or a shared task file under ansible/tasks/), parameterized by backend_code_dir / backend_user.
  2. Both playbooks switch to ansible.builtin.include_tasks (or include_role: tasks_from).
  3. tests/migrations/test_ansible_migration_contract.py already pins the behavioral contract for both playbooks and must stay green unchanged — it resolves included task files or keeps asserting on the rendered playbooks.

Constraint

Pure consolidation — no behavioral change. The contract tests from PR #10039 are the regression net.

Related: PR #10039 (introduced the duplication consciously to keep the strict-mode change reviewable) · #10045 (first change that would otherwise need dual edits).

Activity

  1. github-actions commented on Jun 26, 2026

    @github-actions
    Contributor

    PR #10508 (merged to Dev_new_gui) references this issue with a close keyword.

    refactor(ansible): shared migration-sequence include + registry-driven inventory seeding (#10046, #10110)

    If this issue is fully resolved, close it manually. If work remains, no action is needed.

  2. mrveiss commented on Jun 26, 2026

    @mrveiss
    OwnerAuthor

    Merged to Dev_new_gui (PR #10508). Migration sequence extracted into shared _shared/tasks/migrate_backend_db.yml include, replacing duplicated blocks in setup-user-backend.yml + update-all-nodes.yml. Contract test 11 passed. Batch #10440.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions