Ravindra BagaleCourses & study guides

Chapter 11: Ansible Introduction

11.7 Simple role folder layout

When playbooks grow, split into roles:

roles/
  web_welcome/
    tasks/main.yml
    handlers/main.yml
    files/index.html
    templates/badge-api.conf.j2 # optional later
    defaults/main.yml

Playbook becomes:

- hosts: badge-api_web
  become: true
  roles:
    - web_welcome
Piece Holds
tasks/ Main work
handlers/ Restarts/reloads
files/ Static files for copy
templates/ Jinja2 templates
defaults/ Overridable variables

You do not need Galaxy complexity on day one — one local role is enough muscle memory.

Practice task

Sketch (tree only) a role badge-api_api_user that would create a system user and a /opt/badge-api directory — list which role folders you would touch.