The directory layout for roles
Roles are nothing but directories laid out in a specific manner. Roles follow predefined directory layout conventions and expect each component to be in the path meant for it.
The following is an example of a role, called Nginx:
Let's now look at the rules of the game and what each of the components in the preceding diagram is for:
- Each role contains a directory which is named after itself, for example,
Nginx
, withroles/
as its parent directory. Each named role directory contains one or more optional subdirectories. The most common subdirectories to be present are tasks, templates, and handlers. Each of these subdirectories typically contain themain.yml
file, which is a default file. - Tasks contain the core logic, for example, they will have code specifications to install packages, start services, manage files, and so on. If we consider a role to be a movie, a task would be the protagonist.
- Tasks alone cannot do everything. Considering our analogy with movies...