Open mike-sheppard opened 4 years ago
This is tricky with Trellis / Ansible. Ansible stops immediately when encounters errors.
block
+ rescue
Not excatly what we need - This is an example how we trigger rollback if deployments break critical_urls
---
- import_playbook: deploy.yml
- hosts: web:&{{ env }}
remote_user: "{{ web_user }}"
gather_facts: false
tasks:
- block:
- uri:
url: "https://{{ wordpress_sites[site].site_hosts[0].canonical }}{{ item }}?cache-busting={{ ansible_date_time.epoch }}"
loop: "{{ wordpress_sites[site].critical_urls }}"
connection: local
rescue:
- include_role:
name: rollback
- fail:
msg: "Critical urls are not 200 okay. Site rolled back"
handler
Maybe. Needs more digging.
Do you have any solution in mind?
I had a quick look into rescue
after reading through this - https://www.petewilcock.com/ansible-slack-failure-handler/ but didn't get very far with the Trellis integration - it relies on all tasks being in the same block which doesn't look like we'll be able to do with the way Trellis' deploy playbook is currently organised? + rescue
can't be used for the playbook (as far as I know)
Also, I might be wrong but the only way rescue could work with the current setup is adding it to each of the hooks/tasks which doesn't feel like a clean solution or easy to add and maintain with Trellis updates? Hoping I'm wrong!
It'd be good to have a notification if the deployment fails/aborted by the user.