ARTH — Task 15 👨🏻‍💻

Task 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 challenges for host ip’s addition dynamically over each Managed Node in HAProxy.cfg file.


STEP:1: Install Ansible in controller Node…

cmd: yum install ansible

STEP:2: Create Inventory File…

cmd: vim ip.txt

STEP:3: To create Roles…

*Role for webserver
cmd: ansible-galaxy role init webserver
*Role for load balancer
cnd: ansible-galaxy role init load_balancer


cmd: ls - to see two folders created in the name of roles

STEP:4: Update in ansible config file…

  • Mention the role path in ansible configuration file.

i.e.,the directory in which roles are there

  • Mention the inventory too
cmd: vim /etc/ansible/ansible.cfg

STEP:5: Create a Ansible playbook …

# create the playbook in different directory and mention the roles in it.

STEP:6: Create playbook for roles…

Note:1: create index.php file

Note:2: Install haproxy and update config file in controller node

cmd: yum install haproxy :: to install
cmd: vim /etc/haproxy/haproxy.cfg :: to update

STEP:6.1:For webserver


||STEP:6.1.1: Write playbook for tasks folder.

webserver :: tasks

||STEP:6.1.2: Write playbook for vars folder.

webserver :: vars

||STEP:6.1.3: Write playbook for handlers folder.

webserver :: handlers

STEP:6.2: For loadbalancer


||STEP:6.2.1: Write playbook for tasks folder.

loadbalancer :: tasks

||STEP:6.2.2: Write playbook for vars folder.

loadbalancer :: vars

||STEP:6.1.3: Write playbook for handlers folder.

loadbalancer :: handlers

STEP:7: Run the Ansible — playbook

cmd : ansible-playbook task15.yml

Note:1: check whether packages installed in respective nodes

Note:2:check haproxy config file :: vim /etc/haproxy/haproxy.cfg

Ip have been updated dynamically!!!

Note:3: Check the website