Reverse proxy on AWS instance using ansible!
In this article we are going to deploy reverse proxy on top of the ec2 using ansible. For this task we are going to use one controller node and 2 target nodes. The OS in all the controller node will be the Redhat Linux.
Basic Steps!
First we need to launch the OS on aws and then we will deploy HA proxy over that OS. Hence, we need to write 2 ansible playbooks respectively.
Provisioning of AWS!
Create a workspace where you will write all the playbooks and where HAproxy configuration will be copied. In my case I named it as “Work”!
Then we need to configure our ansible configuration file for the task as shown in the picture below.
Now add the IPs to the inventory file.
Now you need to install Python3, BOTO and BOTO3 in localhost, in my case they were already there but you can install them using yum command or by using ansible playbook on ansible localhost.
Now code for launching ec2 instance is given below
Here you need to enter you access and secret key
As you can see the playbook is running
You can also see in AWS dashboard to confirm the above code!
Deploy HAProxy
For this the playbook is given below
Now run the playbook and then you can see the result
Hence this is how you can enable HAproxy on AWS!