As suggested by @mkanoor in another PR, this one separates the retry logic from the main code for pre-post-migration playbooks.
Feature tracked in another BZ. Closing to ease QA. *** This bug has been marked as a duplicate of bug 1564250 ***