Defining an error condition

The ignore_errors condition is a bit of a blunt instrument. Any error generated from the module used by the task will be ignored. Furthermore, the output, at first glance, still appears like an error, and may be confusing to an operator attempting to discover a real failure. A more subtle tool is the failed_when condition. This condition is more like a fine scalpel, allowing a playbook author to be very specific as to what constitutes an error for a task. This condition performs a test to generate a Boolean result, much like the when condition. If the condition results in a Boolean true, the task will be considered a failure. Otherwise, the task will be considered successful.

The failed_when condition is quite ...

Get Mastering Ansible - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.