I have the following playbook with 3 plays. When one of the plays fail, the next plays still execute. I think it is because I run those plays with a different host target.
I would like to avoid this and have the playbook stop when one play fails, is it possible?
---
- name: create the EC2 instances
  hosts: localhost
  any_errors_fatal: yes
  connection: local
  tasks:
    - ...
- name: configure instances
  hosts: appserver
  any_errors_fatal: yes
  gather_facts: true
  tasks:
   - ...
- name: Add to load balancer
  hosts: localhost
  any_errors_fatal: yes
  vars:
    component: travelmatrix
  tasks:
    - ...
You can use any_errors_fatal which stops the play if there are any errors.
- name: create the EC2 instances
  hosts: localhost
  connection: local
  any_errors_fatal: true
  tasks:
   - ...
Reference Link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With