Skip to content

fix: guard destructive replication/teardown Ansible tasks against re-runs - #70

Merged
michaelcoburn merged 1 commit into
percona:mainfrom
michaelcoburn:fix/guard-destructive-tasks
Jun 2, 2026
Merged

fix: guard destructive replication/teardown Ansible tasks against re-runs#70
michaelcoburn merged 1 commit into
percona:mainfrom
michaelcoburn:fix/guard-destructive-tasks

Conversation

@michaelcoburn

Copy link
Copy Markdown
Collaborator

Closes #56 (scoped — see note)

The mysql2/mysql3 provisioning tasks reset replication and DROP the lab databases (imdb/world/sakila/sysbench) via raw shell, with no idempotency guard. The README tells instructors they can re-run the playbook (and the --limit flow re-provisions a single node) — but re-running these on an already-configured node would tear down a working replica or wipe student data.

Change

Add creates: sentinel guards so each runs once at initial provision and is skipped on re-runs:

  • Connect Async Replication/var/lib/mysql/.training_async_repl_done
  • GROUP REPLICATION - Drop everything…/var/lib/mysql/.training_gr_reset_done

(The marker is only written after the mysql command succeeds, so a failed run safely retries. db2's package removal is already guarded by its existing_setup stat check.)

Scope note

Deliberately scoped to guarding the destructive tasks rather than a full idempotency refactor of hosts.yml — the training instances are ephemeral, so the high-value win is "a re-run never wipes data," not rewriting every shell task. The broader refactor can remain a someday-maybe.

Verification

ansible-lint hosts.yml roles/Passed: 0 failure(s); YAML parses clean.

The mysql2/mysql3 provisioning tasks reset replication and DROP the lab
databases (imdb/world/sakila/sysbench) via raw shell, with no idempotency
guard. Re-running the playbook on an already-provisioned node (the
documented `--limit` re-provision flow, or a retry after a partial
failure) would tear down a working replica or wipe student data.

Add `creates:` sentinel guards so each runs once at initial provision and
is skipped on re-runs:
- Connect Async Replication -> /var/lib/mysql/.training_async_repl_done
- GROUP REPLICATION drop/reset -> /var/lib/mysql/.training_gr_reset_done

Scoped per discussion to guarding the destructive tasks only (not a full
idempotency refactor) since the instances are ephemeral. db2's package
removal is already guarded by its existing_setup stat check.

Closes percona#56

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@michaelcoburn
michaelcoburn merged commit 58597e2 into percona:main Jun 2, 2026
4 checks passed
@michaelcoburn
michaelcoburn deleted the fix/guard-destructive-tasks branch June 2, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor Ansible tasks for idempotency

1 participant