Travis Bear
Travis Bear

Reputation: 13859

Possible to abort mid-task on error?

Given a task that performs a service restart on five different hosts, is it possible to tell ansible that if the restart fails on host1, to abort the entire run without doing the restart on hosts 2-5?

The any_errors_fatal setting combined with --forks=1 and serial: 1 settings all seem promising but don't seem to it.

- hosts: all
  serial: 1
  any_errors_fatal: true
  become: yes
  roles:
    - service_control

Upvotes: 3

Views: 128

Answers (1)

helloV
helloV

Reputation: 52385

Can you try setting max_fail_percentage to zero? From Maximum Failure Percentage

- hosts: all
  serial: 1
  max_fail_percentage: 0
  become: yes
  roles:
    - service_control

Upvotes: 3

Related Questions