Book Image

Mastering Ansible

Book Image

Mastering Ansible

Overview of this book

Table of Contents (16 chapters)

Roles


With a functional understanding of the inclusion of variables, tasks, handlers, and playbooks, we can move on to the more advanced topic of Roles. Roles move beyond the basic structure of a few playbooks and a few broken-out files to reference. Roles provide a framework for fully independent, or interdependent, collections of variables, tasks, files, templates, and modules. Each role is typically limited to a particular theme or desired end result, with all the necessary steps to reach that result either within the role itself or in other roles listed as dependencies. Roles themselves are not playbooks. There is no way to directly execute a role. Roles have no setting for which host the role will apply to. Top-level playbooks are the glue that binds the hosts from your inventory to roles that should be applied to those hosts.

Role structure

Roles have a structured layout on the file system. This structure exists to provide automation around, including tasks, handlers, variables, modules...