You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
ansible-role-nginx/lamp_haproxy/README.md

51 lines
2.0 KiB

LAMP Stack + HAProxy: Example Playbooks
-----------------------------------------------------------------------------
11 years ago
This example is an extension of the simple LAMP deployment. Here we'll deploy a web server with an HAProxy load balancer in front. This set of playbooks also have the capability to dynamically add and remove web server nodes from the deployment. It also includes examples to do a rolling update of a stack without affecting the service.
11 years ago
###Setup Entire Site.
First we configure the entire stack by listing our hosts in the 'hosts' inventory file, grouped by their purpose:
11 years ago
11 years ago
[webservers]
web3
web2
[dbservers]
web3
[lbservers]
11 years ago
lbserver
11 years ago
After which we execute the following command to deploy the site:
11 years ago
11 years ago
ansible-playbook -i hosts site.yml
The deployment can be verified by accessing the IP address of your load balnacer host in a web browser: http://<ip-of-lb>:8888. Reloading the page should have you hit different webservers.
11 years ago
###Remove a Node
11 years ago
Removal of a node from the cluster is as simple as executing the following command:
ansible-playbook -i hosts playbooks/remove_webservers.yml --limit=web2
###Add a Node
11 years ago
11 years ago
Adding a node to the cluster can be done by executing the following command:
ansible-playbook -i hosts playbooks/add_webservers.yml --limit=web2
###Rolling Update
Rolling updates are the preferred way to update the web server software or deployed application, since the load balancer can be dynamically configured to take the hosts to be updated out of the pool. This will keep the service running on other servers so that the users are not interrupted.
In this example the hosts are updated in serial fashion, which means
that only one server will be updated at one time. If you have a lot of web server hosts, this behaviour can be changed by setting the 'serial' keyword in webservers.yml file.
11 years ago
Once the code has been updated in the source repository for your application which can be defined in the group_vars/all file, execute the following command:
11 years ago
11 years ago
ansible-playbook -i hosts playbooks/rolling_update.yml
11 years ago