From the course: Ansible: From Basics to Guru by Pearson

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Understanding and using roles

Understanding and using roles

So, let's talk about roles. Some tasks are used a lot in Ansible. And instead of defining these tasks yourself all the time, you can use Ansible roles. A role is a set of ready-to-use tasks that is easily integrated in a playbook and which is provided by the community. You can find them at galaxy.ansible.com. Roles can also be installed through packages, such as the rel system-roles.rpm package on Red Hat. And alternatively, you can even develop custom roles. You'll learn later how to do that. Now before you are going to use roles, they need to be installed. Roles are typically installed in one of the following directories. UserShareAnsibleRole. That will be the default role path. etcAnsibleRoles. or the dot slash roles directory in your current project path. And if you want to install them anywhere else, you can use the roles path option in ansible.cfg to define an alternative roles path. And after installing roles, they can be used from playbooks. Now if a role is going to be used…

Contents