Since Ansible execute the tasks in order, will it skip to the next task if the current task failed?
Since Ansible execute the tasks in order, will it skip to the next task if the current task failed?
As documented in Error handling in playbooks :
When Ansible receives a non-zero return code from a command or a failure from a module, by default it stops executing on that host and continues on other hosts.
[...]
You can use
ignore_errorsto continue on in spite of the failure
From the Ansible docs:
By default Ansible stops executing tasks on a host when a task fails on that host. You can use ignore_errors to continue on in spite of the failure.
- name: Do not count this as a failure
ansible.builtin.command: /bin/false
ignore_errors: yes
The ignore_errors directive only works when the task is able to run and returns a value of ‘failed’. It does not make Ansible ignore undefined variable errors, connection failures, execution issues (for example, missing packages), or syntax errors.
REFERENCES:
Ansible docs: Error handling in playbooks: https://docs.ansible.com/ansible/latest/user_guide/playbooks_error_handling.html#error-handling-in-playbooks