DEV Community

loading...
Cover image for Configuration of HAProxy using Ansible in AWS

Configuration of HAProxy using Ansible in AWS

Nitesh Thapliyal
I'm an Information technology student. I'm passionate about current and emerging technologies. I have always been fascinated by how things work, functionality, and problem-solving.
・2 min read

Hello everyone,

In this article, we are going to configure HAProxy using Ansible in AWS,

So let's get started...

I have launched three instances in aws👇

Alt Text

Configuration of Control Node:

Install Ansible in Control Node

To install Ansible use command pip3 install ansible and then install sshpass using command yum install sshpass

Create Inventory

After installing Ansible create an Inventory anywhere in the system, here I have created an inventory named ip.txt and inside inventory put Managed Node username, Password, and the connection type.

Alt Text

Here I have created group one of the load balancer and other of Backend Server.

Check the connectivity of Managed Node

To check connectivity using command ansible all -m ping.

Alt Text

Create Ansible Configuration file

Alt Text

Create Playbook

Alt Text

Configure Haproxy file

Alt Text

  • Before we run the playbook lets check first is Haproxy is installed in the Control node or not, to check that use command rpm -q haproxy

Alt Text

Here we can see Haproxy is not installed.

Run the Playbook.

Alt Text

  • now check Haproxy is installed in the Control node or not

Alt Text
Alt Text

Here you can see Haproxy is installed and launched successfully...

  • Check in Managed node is webserver configured or not

Alt Text

Here you can see it is configured successfully...

Check Haproxy or Load balancer is working or not

Alt Text
Alt Text

Here you can see it is working...🙌

So that's how we can configure Haproxy in AWS using Ansible...

Thank you!❄

Discussion (0)