An 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. A role directory structure contains directories: defaults, vars, tasks, files, templates, meta, handlers.
Creation and setup of your own Ansible Role in a RHEL system.
Step 1: Install system roles.
Step 2: To create your own roles configure your ansible.cfg file located in /etc/ansible/ansible.cfg as shown below:
Step 3: Initiate your Role
Step 4: Get into the directory and look for the main.yml file for writing tasks for your role.
Step 5: Write your tasks in the file.
Step 6: Create the file for running your role.
Step 7: Run the file
Step 8: Result: