Menu

Ansible Roles and Ansible Galaxy

Ansible Roles and Ansible Galaxy

Understanding Ansible Roles and Their Directory Structure

Roles package related tasks, handlers, templates, files, defaults, variables and metadata into a reusable structure. A role separates what a component configures from the play that invokes it.

Creating and Reusing Roles for Configuration Management

TYPICAL ROLE STRUCTURE

roles/

└── nginx/

├── defaults/main.yml

├── handlers/main.yml

├── tasks/main.yml

├── templates/nginx.conf.j2

└── vars/main.yml

Put broadly overridable values in defaults. Use role vars only when a value should have higher precedence and should not normally be overridden.

Using Ansible Galaxy to Discover, Install and Share Roles

Ansible Galaxy provides a community for sharing roles and collections. Review ownership, maintenance, dependencies, supported versions, and security before installing third-party content.

Pin versions in requirements files and install dependencies reproducibly. Do not treat community content as trusted merely because it is published in Galaxy.


Ansible Tutorial

HA

Harini A



Learn via Video Course

undefined Logo

NaN hrs



Get in Touch For Details