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.

Using blocks

Using blocks

- [Instructor] Using basic Ansible constructs, we can group tasks by creating Separate playbook files, and then importing or including them when they're needed. We can combine this with conditionals, and even simulate group-level error handling, at least to a degree. However, Ansible includes support for blocks, which allows us a logical grouping of tasks with error handling. We can apply most things to a block just as we would a task. This includes setting data or directives for the block such as become and become user if we're using them. Any of these directors that we set at the block level, get inherited by all tasks inside of it. In this chapters exercise files, I've included a script called ansible-block.yml. Let's take a look at it. On our toast one, go into your exercise files directory and into this chapter sub-directory. Now view the Ansible block file using VIM or another editor. For VIM have been VIM…

Contents