Asked by: Rabab Kaletskyasked in category: General Last Updated: 22nd May, 2020
What is the role in Ansible?
Similarly, it is asked, what is the use of role in Ansible?
Ansible role is an independent component which allows reuse of common configuration steps. Ansible role has to be used within playbook. Ansible role is a set of tasks to configure a host to serve a certain purpose like configuring a service. Roles are defined using YAML files with a predefined directory structure.
One may also ask, how do I create an Ansible role?
- Step 1 - Setup Ansible Playbook Project.
- Step 2 - Generate Ansible Roles for the Directory Structure.
- Step 3 - Setup hosts and site.
- Step 3 - Setup Common Roles.
- Step 4 - Setup 'web' Roles.
- Step 5 - Setup 'db' Roles.
- Step 6 - Run the Ansible Playbook.
- Step 7 - Testing.
Regarding this, what are the advantages of using Ansible roles?
Roles are designed to be reusable. Organizing playbooks with roles allows you to reuse different modules and avoid code duplication. Repetitive configuration steps, carried out into separate files, can be used many times, simply by including the required role functionality in your playbooks when necessary.
What is the difference between roles and playbook in Ansible?
Ansible playbook is a script file which contains all the tasks that need to be performed along with all the ingredients required to perform these tasks. Roles are ways of automatically certain var files, tasks, and handlers based on the known file structure.