HAProxy Configuration On AWS Using Ansible

🔰Task: Using Ansible Playbook, Configure Reverse Proxy i.e. Haproxy, and update its configuration file automatically each time a new Managed node (Configured With Apache Webserver) joins the inventory on AWS

Pre-requisites:

  1. AWS EC2 instances- At least two
  2. Installed Ansible on the control node

Step 1: Configure Ansible

Create a directory using the command: mkdir /etc/ansible

add the inventory file location in the ansible configuration file: ansible.cfg and write host_key_checking=False to disable the ssh key and provide privilege escalation.

Step 2: Create Inventory File

Add the ec2 instance IP address, username, private key, and connection type.

Step 3: Check the connectivity

Check the connectivity of the control node with managed nodes

Command: ansible all -m ping

Step 4: Create a Jinja file for haproxy.cfg

Create a jinja file for haproxy.cfg(.j2 extension) and write the following code in it.

Step 5: Write Code in the Playbook

Step 6: Run the playbook

To run the ansible-playbook use Command: ansible-playbook <file_name.yml>

Step 7: Check the load Balancers

Check the haproxy.cfg file.

Use Command: vim /etc/haproxy/haproxy.cfg

haproxy.cfg file

Haproxy successfully configured on load balancer node.

Now, Check whether the 8080 port is running or not

Use Command: netstat -tnlp

p

It’s working perfectly fine:)

😊Thank you for Reading😊

--

--

--

An enthusiast learner

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Flutter: Implementing Google Sign In

When I prevented the situation to go out of hand

CS373 Fall 2021: Andrew Wu

Scaling Infrastructure Workflows

How To Become a DevOps Engineer In Six Months or Less, Part 5: Deploy

Automated Machining System

Ubuntu 20.04 startup and shutdown a database instance

How to Monitor and Analyze metrics with the integration of Prometheus and Grafana and also make…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kriti Dubey

Kriti Dubey

An enthusiast learner

More from Medium

How to Rename an AWS S3 Bucket in Terraform

Hostin a Static Website on AWS S3 using Terraform

Manage on-premise instances using AWS System Manager and Terraform

Deploying ‘n’​ Cisco FTDv in AWS in multiple Availability Zones using Terraform