A task condition, named ignore_errors, is used to ignore errors. This condition is a Boolean, meaning that the value should be something Ansible understands to be true, such as yes, on, true, or 1 (string or integer).
To demonstrate how to use ignore_errors, let's create a playbook where we attempt to query a web server that doesn't exist. Typically, this would be an error, and if we don't define ignore_errors, we get the default behavior, that is, the host will be marked as failed and no further tasks will be attempted on that host. Create a new playbook called error.yaml as follows to look further at this behavior:
---
- name: error handling
hosts: localhost
gather_facts: false
tasks:
- name: broken website
uri:
url: http://notahost.nodomain
Running the task as is will give us the following error:
Now, let's imagine that we didn't want Ansible to stop here, and instead we wanted it to continue. We can add the ignore_errors condition to our task like this:
- name: broken website uri: url: http://notahost.nodomain ignore_errors: true
This time, when we run the playbook, our error will be ignored, as we can see here:
Any further tasks for that host will still be attempted and the playbook does not register any failed hosts.