Latest Updates

Configure HAPROXY Using Ansible Automation Tool

 

HAPROXY

RED HAT ANSIBLE

APACHE WEB SERVER

Task Objective :



step5. start the HAPROXY services.

To get a true feeling of automation please use playbook only do not use any command in between

NOTE: all the source code is in GitHub linked provide in the last

Let’s Get Started

To install an ansible automation tool run the following command:
pip3 install ansible
etc/ansible/                          // ansible directory
[HAPROXY]192.168.0.112  ansible_connection=ssh ansible_user=root ansible_ssh_pass=root[WebServer]192.168.0.113 ansible_connection=ssh ansible_user=root ansible_ssh_pass=root192.168.0.108 ansible_connection=ssh ansible_user=root ansible_ssh_pass=root
#### variables used in HAPROXY configuration file #####- LoadBlancer_port: 8080- WebServer_port: 80
ansible all -m ping

ansible-playbook FileName.yml


haproxy.cfg filefrontend mainbind *:{{ LoadBlancer_port }}   // here we will add port for haproxy#-------------------------------------------------------------------# round robin balancing between the various backends#-------------------------------------------------------------------backend appbalance     roundrobin{% for ip in groups['WebServer'] %}  

// we used loop because we have many servers
server app{{loop.index}} {{ ip }}:{{ WebServer_port }} check{% endfor %}





http://"haproxy server ip":"listening port" Actual Backend server that is used by haproxy

192.168.0.108
192.168.0.113


No comments