fix: guard destructive replication/teardown Ansible tasks against re-runs - #70
Merged
michaelcoburn merged 1 commit intoJun 2, 2026
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #56 (scoped — see note)
The
mysql2/mysql3provisioning tasks reset replication and DROP the lab databases (imdb/world/sakila/sysbench) via rawshell, with no idempotency guard. The README tells instructors they can re-run the playbook (and the--limitflow 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_doneGROUP REPLICATION - Drop everything…→/var/lib/mysql/.training_gr_reset_done(The marker is only written after the
mysqlcommand succeeds, so a failed run safely retries.db2's package removal is already guarded by itsexisting_setupstat 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.