Configure the Load Balancer using ansible playbook over AWS ec2-instances

Shobhit Singh Pal
2 min readDec 16, 2020

Check out this https://pshobhitsingh01.medium.com/use-ansible-playbook-to-configure-reverse-proxy-i-e-8dcaa2c04dc7 where i explained how set up the load balancer using ansible playbook on virtual machines.

In case of aws instances only the inventory file changes. For ssh in the aws instances instead of password ,key is required.

The inventory will look like:

Here the parameters are:

ansible_user: user which will be login to managed nodes by ssh.

ansible_connection: tells the protocol or connection type to login into managed nodes.

ansible_ssh_private_key: it is the key which will be used as authentication in managed nodes or instances.

ansible_become: to become user other than that logged in managed nodes. As ec2-user does not have privilages to run the commands like yum. This other user in ansible is called as become. This become runs the command with sudo privilage.

Using the same ansible playbook as used in https://pshobhitsingh01.medium.com/use-ansible-playbook-to-configure-reverse-proxy-i-e-8dcaa2c04dc7

The haproxy file :

Running ansible-playbook as:

ansible-playbook task.yml

So now checking the output:

Now as soon as more traffic will come load balancer will route the traffic to other web servers.

Conclusion: Setting the load balancer on aws instances is now being used a lot. Many peoples are using aws to host the website.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Shobhit Singh Pal
Shobhit Singh Pal

No responses yet

Write a response