Repository navigation
Conversation
When a deployment fails before activation, the failed release folder is removed by the rescue block. The new opt-in variable ansistrano_keep_failed_release keeps it around for debugging. Also rework the failed release tests in test/rsync-test.yml: play-level ignore_errors bypassed the role's block/rescue, so the rescue path was never exercised. Use block/rescue with include_role and real asserts, and cover both branches (release removed by default, kept when the new variable is set).
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.
Summary
When a deployment fails before activation, the rescue block in
tasks/main.ymlremoves the failed release folder. This makes post-mortem debugging hard, since the partially deployed code (and any logs/artifacts inside the release) is gone.This PR adds an opt-in variable
ansistrano_keep_failed_release(defaultfalse, so existing behaviour is unchanged). When set totrue, the failed release folder is kept for debugging.Changes
tasks/main.yml: skip the "Remove failed release" rescue task whenansistrano_keep_failed_releaseis truthy (uses| default(false) | bool, consistent withansistrano_git_identity_key_shred)defaults/main.yml,docs/role-variables.md: declare and document the new variabletest/rsync-test.yml: rework the failed-release tests and cover both branchesTest rework details
The existing failed-release tests (from ansistrano#410) were vacuous for two reasons:
ignore_errors: yesbypasses the role'sblock/rescue: the failing hook task is ignored and the deployment simply continues, so the rescue path (and the cleanup it performs) was never exercised (rescued=0in the recap).ansistrano_release_versioninto subsequent plays viaset_fact, so the play-level version vars never took effect.The tests now use
block+include_role+rescueand realasserttasks, with a deterministic release version set viapre_tasks: set_fact:ansistrano_keep_failed_release: true→ release is kept (assert)Verification
./scripts/test-in-docker.sh integration): green,failed=0,rescued=4(exactly the two new rescue pairs)tasks/main.ymlmakes the new suite fail exactly at the "kept" assertion; with the flag set tofalse(including as a string via-e) the release is correctly removed--syntax-checkontest/main.yml: green