Setting-Up Apache LoadBalancer With Ansible
- Before we start using ansible for setting-up LB. lets create a lb-config.j2 which will our this will be configuration template of our LB, create in /home/ec2-user/ansible/config
vim lb-config.j2
Content of lb-config.j2
ProxyRequests off <Proxy balancer://webcluster > {% for hosts in groups['webservers'] %} BalancerMember http://{{hostvars[hosts]['ansible_host']}} {% endfor %} ProxySet lbmethod=byrequests </Proxy> # Optional <Location /balancer-manager> SetHandler balancer-manager </Location> ProxyPass /balancer-manager ! ProxyPass / balancer://webcluster/
- Go to playbooks directory on ansible host and create setup-app.yml
vim setup-lb.yml
- Content of setup-app.yml, Click Here!
- Now run your playbook with:
ansible-playbook setup-lb.yml