From the course: Ansible: From Basics to Guru by Pearson

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Managing failure with the fail module

Managing failure with the fail module - Ansible Tutorial

From the course: Ansible: From Basics to Guru by Pearson

Managing failure with the fail module

In this video, you'll learn how to manage failure using the fill module. So let's talk about failure handling in general first. When you run a playbook, Ansible looks at the exit status of a task to determine whether it has failed. Every task runs a command, and the exit status is just as it is in any other command. Exit status 0 means successful, exit status non-zero means that it was not successful. So if Ansible receives an exit status non-zero, it considers the tasks to be failing. And that is a problem in non-idempotent modules like the command module, as we have seen before. If a failure occurs, Ansible aborts the rest of the play on that host and continues with the next host. If you don't want that, there's a couple of solutions. You can use ignoreErrors in a task or also on a play to ignore failures. You can also use forceHandlers to force a handler that has been triggered to run, even if another task fails. We have seen that before. If ignoreErrors is set to yes and…

Contents