Apply Roles & Pass Role Variables
Include a role and parameterize it.
Apply a Role with roles:
The simplest way to use a role is the roles key in a play. List the role names and Ansible runs each one in order.
- hosts: web
roles:
- nginx
- firewallRoles Run Before Tasks
Roles listed under roles execute before any tasks in the same play. Keep that ordering in mind when mixing roles and tasks.
All lessons in this course
- Why Roles: From Monolith to Modules
- The Role Directory Anatomy
- Scaffold a Role with ansible-galaxy init
- Apply Roles & Pass Role Variables