feat: add cleanup playbooks for migration test environments#51
Merged
Conversation
Add idempotent Ansible roles and playbooks to reset Bootstrap AAP, Migration AAP, and OpenShift cluster artifacts after migration testing. New roles: - aap_cleanup: discovers and removes AAP resources via controller API, supports dry-run mode and parameterized provider filtering - ocp_cleanup: removes MTV CRDs, secrets, migrated VMs/PVCs, and optionally tears down operators with dependency-aware deletion order New playbooks: - cleanup_bootstrap_aap.yml - cleanup_migration_aap.yml - cleanup_ocp_migration_artifacts.yml - cleanup_all.yml (aggregator for CI pipeline integration) Includes molecule test scenarios and integration test targets. Resolves: MFG-382
There was a problem hiding this comment.
ansible-lint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
- Add `_filename | ` prefix to all task names in included task files (ansible-lint name[prefix] rule) - Fix cleanup_all.yml: replace invalid `ignore_errors` on `import_playbook` with block/rescue pattern per playbook schema - Add document end markers `...` to molecule files - Regenerate role READMEs via docsible (pre-commit hook requirement)
- Move Jinja templates to end of task names (name[template] rule) - Replace all ignore_errors with failed_when: false (ignore-errors rule) - Add noqa for controller_dependency_check var required by dispatch - Remove duplicate License heading (MD024 — docsible generates its own) - Regenerate docsible documentation
- Default validate_certs to true when env lookup returns empty string (prevents 'not a valid boolean' error in uri module) - Rewrite integration tests to validate role defaults loading and variable assertions instead of calling roles that need live AAP/OCP
Integration tests run in molecule temp directories where relative paths to role defaults don't resolve. Switch to ansible-doc role introspection which works against the installed collection path.
sabre1041
requested changes
Jul 8, 2026
sabre1041
left a comment
Contributor
There was a problem hiding this comment.
A few comments from the initial review. Lots of good stuff here @stevefulme1
Remove bootstrap cleanup playbook and play — bootstrap concept no longer exists. Add _aap_cleanup_use_org_filter: false to hosts and credential_types tasks where the AAP API does not support organization-scoped queries.
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
aap_cleanupandocp_cleanuproles with idempotent cleanup automation for migration test environmentscleanup_all.yml) for CI integrationWhat this solves
MFG-382 — The collection creates resources across 3 systems (Bootstrap AAP, Migration AAP, OpenShift cluster) during migration testing but has zero teardown automation. Tests leave stale resources with no clean slate between cycles.
New roles
aap_cleanupaap_seedtemplates)aap_cleanup_dry_run: true)cleanup_providers: [vmware, ovirt])ocp_cleanupocp_cleanup_dry_run: true)New playbooks
cleanup_bootstrap_aap.ymlcleanup_migration_aap.ymlcleanup_ocp_migration_artifacts.ymlcleanup_all.ymlignore_errorsfor CICI pipeline integration
A separate PR will be needed in
openshift_virtualization_migration_cito add a_cleanup-stage.ymlworkflow that runscleanup_all.ymlas a post-test step (withif: always()). Draft spec available.Test plan
yamllintpasses on all new files (verified locally)ansible-lintpasses on new roles and playbookscleanup_all.ymlcontinues execution when one sub-playbook failsJira
Resolves MFG-382
Related tasks: