From the course: Red Hat Certified Engineer (EX294) Cert Prep: 2 Using Ansible Playbooks

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Block error handling

Block error handling

- [Instructor] If you only look at blocks as a way of executing multiple tasks based on a condition, then you'll be missing a very important feature of Ansible. Most modern programming languages have a concept of exceptions. Exception handling is the process of responding when an unexpected event happens that requires special processing. Exception handling attempts to gracefully handle the situation. Blocks give Ansible the ability to handle exceptions. It is important to note that the exception handling in blocks only deals with tasks with failed status. Block error handling does not handle tasks with improper syntax, bad definitions, or unreachable hosts. These are not exceptions that block error handling can deal with. I've included a script named block-exceptions.yml in this chapter's exercise files. Change into that directory and load it into Vim or another editor. If you're using Vim, type in vim space,…

Contents