0Pricing
Ansible Academy · Lesson

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
    - firewall

Roles 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

  1. Why Roles: From Monolith to Modules
  2. The Role Directory Anatomy
  3. Scaffold a Role with ansible-galaxy init
  4. Apply Roles & Pass Role Variables
← Back to Ansible Academy