Arth Task: 12.2
Use Ansible playbook to Configure Reverse
Proxy i.e. Haproxy and update it’s configuration
file automatically on each time new Managed node
(Configured With Apache Webserver) join the inventory on AWS EC2.
Reqirements:
AWS EC2 instances(1 as controller node and other two as managed node) and pre insatlled ansible in controller node
To run cmd on AWS while running ansible playbook, it should run with root power for this we have to provide privilege escalation in configuration file of ansible:

Inventory file:

Creating a jinja file for haproxy.cfg with extension .j2 which will create the configuration file dynamically:

Ansible-playbook:

Also the configuration file of haproxy here the ip is dynamically updated of managednode:

Now adding one more Managednode into inventory file of our backened server:

Running the playbook:


Configuration file of haproxy(host) is dynamically updated with added new targetnode:

At target node(new) the httpd services started with port no 80:

output of web page access through target nodes as:
