Configure Httpd WebServer And HAProxy LB by ANSIBLE ROLE
Introduction:
🔅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.
Requirements:
For performing this task we need 3 operating system , here we have used Red Hat linux , you can use any .
Three VM IP’s are :
STEPS TO DO :
STEP 1: created a directory name pb1
#mkdir pb1
STEP 2: go in the directory
# cd pb1
STEP 3: created 2 role
#ansible-galaxy init myapache
#ansible-galaxy init myloadbalancer
Two roles created :
STEP 4: configuring tasks folder in myapache role
#cd pb1/myapache/tasks/main.yml
STEP 5: crating html page in myapache role in template
#cd pb1/myapache/template/index.php
STEP 6:configuring task in myloadbalancer role
#cd pb1/myloadbalancer/tasks/main.yml
STEP 7:update haproxy file
# cd /etc/haproxy/haproxy.cfg
solving challenge for host ip’s addition dynamically over each Managed Node in HAProxy.cfg file.
STEP 8: configuring handlers in myloadbalancer role
# cd pb1/myloadbalancer/handlers/main.yml
STEP 9: created playbook name task15.yml in pb1 directory
# cd pb1
# vim task15.yml
STEP 10: Run the playbook
# ansible-paybook pb1/task15.yml
STEP 11: results
Finally!!! our set up is done.
Refer to the code below for any confusion.