Configure the Load Balancer using ansible playbook over AWS ec2-instances
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.