ARTH_TASK 15

Swapnilsukare
3 min readJan 14, 2022

DESCRIPTION:

🔅Create an ansible role myapache to configure Httpd WebServer.

🔅Create another ansible role myloadbalancer to configure HAProxy LB.

🔅We need to combine both of these roles controlling webserver versions
and solving challenge for host ip’s addition dynamically over each Managed
Node in HAProxy.cfg file.

What is Ansible Roles?

Roles provide a framework for fully independent, or interdependent collections of variables, tasks, files, templates, and modules.

In Ansible, the role is the primary mechanism for breaking a playbook into multiple files. This simplifies writing complex playbooks, and it makes them easier to reuse. The breaking of playbook allows you to logically break the playbook into reusable components.

Each role is basically limited to a particular functionality or desired output, with all the necessary steps to provide that result either within that role itself or in other roles listed as dependencies.

Roles are not playbooks. Roles are small functionality which can be independently used but have to be used within playbooks. There is no way to directly execute a role. Roles have no explicit setting for which host the role will apply to.

#Inventory file
vim ip.txt
#Pinging all the managed nodes to check connectivity
ansible all -m ping
#We create ansible roles before writing the playbooks ansible-galaxy init /etc/ansible/roles/apache          #For HTTPD

ansible-galaxy init /etc/ansible/roles/haproxy #For HAProxy

Task 15.1 Description

🔅Create an ansible role myapache to configure Httpd WebServer.

Task file for HTTPD role

Task 15.2 Description

🔅Create another ansible role myloadbalancer to configure HAProxy LB.

Task file for HAProxy

Task 15.3 Description

🔅We need to combine both of these roles controlling webserver versions and    solving challenge for host ip's addition dynamically over each Managed Node in  HAProxy.cfg file.

Ansible playbook to configure HTTPD and HAProxy

Connecting to the Loadbalancer IP using 8080 port to check if it’s working or not.

THANKS FOR READING….!!

KEEP SHARING..!!

KEEP GROWING..!!

--

--