Interview Prep/Ansible/Rolling Updates, Delegation and Safe Deployments

How do you roll back a bad Ansible deployment?

AdvancedProductionRolling Updates, Delegation and Safe Deployments
Answer

Design for it up front:

  • Deploy into versioned release directories with a current symlink, so rollback is repointing the link and restarting.
  • Keep the previous N releases and the previous config versions (backup: true).
  • Parameterise the version (app_version), so rollback is the same playbook with the old version, or a dedicated rollback.yml.
  • Use block/rescue to revert automatically if the health check fails.

Things Ansible cannot undo: destructive database migrations, deleted data, external side effects. Make migrations backward compatible (expand and contract), so the old code still works on the new schema.

All Ansible questions Roadmap: Ansible

More on Rolling Updates, Delegation and Safe Deployments