So far you have been creating Ansible playbooks to automate a certain task on your managed nodes. There is a huge chance that someone else has already designed an Ansible solution to the problem/task you are trying to solve and that’s exactly what Ansible roles is all about.
In this tutorial, you will understand how roles are structured in Ansible. You will also learn to use ready-made roles from Ansible Galaxy.
Furthermore, you will learn to create your own custom Ansible roles.
Before you proceed with this tutorial, please refer to other chapters in the Ansible tutorial series for better understanding of various topics mentioned here.
Understanding Ansible Roles
An Ansible role is a collection of files, tasks, templates, variables, and handlers that together serve a certain purpose like configuring a service. Roles allows you to easily re-use code and share Ansible solutions with other users which makes working with large environments more manageable.