How to create your own ansible role…

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.

Apache Webserver Role

Step 6: Create the file for running your role.

any playbook

Step 7: Run the file

Step 8: Result:




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store