How do you deploy application releases idempotently with a rollback path?
IntermediateProductionRolling Updates, Delegation and Safe Deployments
Answer
Use release directories and an atomic symlink swap, so each deploy is a new directory and the switch is instantaneous.
- ansible.builtin.unarchive:
src: "{{ artifact_url }}"
dest: "/srv/app/releases/{{ app_version }}"
remote_src: true
creates: "/srv/app/releases/{{ app_version }}/.deployed"
- ansible.builtin.file:
src: "/srv/app/releases/{{ app_version }}"
dest: /srv/app/current
state: link
notify: Restart app
Clean old releases with find and keep the last five. Rollback is the same symlink task with the previous version, followed by a restart.
More on Rolling Updates, Delegation and Safe Deployments
How do you do a rolling update with Ansible?BeginnerWhat forms can `serial` take?IntermediateShow the standard pattern for a zero-downtime rolling deploy behind a load balancer.IntermediateWhy do you add a health check inside the deployment play?BeginnerHow do `any_errors_fatal` and `max_fail_percentage` help a rollout?BeginnerHow do you do a canary deployment?Intermediate