I can think of a couple of ways.
You can force a fail at the end of block if any hosts failed:
- block:
- name: Update database schema
shell: cd '{{ ansible_web_deployment_webroot }}/releases/{{
ansible_web_deployment_release }}' && php7.1 console.php
orm:schema-tool:update --f
orce
when: inventory_hostname in groups['schema']
- name: Deployment
debug:
msg: 'Deploying'
- fail:
when: ansible_play_hosts|length != ansible_play_hosts_all|length
rescue:
- name: Rollback
debug:
msg: 'Rollback'
any_errors_fatal: true
Or delegate rescue to all hosts:
- block:
- name: Update database schema
shell: cd '{{ ansible_web_deployment_webroot }}/releases/{{
ansible_web_deployment_release }}' && php7.1 console.php
orm:schema-tool:update --f
orce
when: inventory_hostname in groups['schema']
- name: Deployment
debug:
msg: 'Deploying'
rescue:
- name: Rollback
debug:
msg: 'Rollback'
delegate_to: '{{item}}'
loop: '{{ ansible_play_hosts_all }}'
any_errors_fatal: true
--
----------
Brian Coca
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CACVha7cpmKv6HTi78KYDcePNF%3DgBmJD9REceWitEzOGbDisFaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.