Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bennojoy committed Mar 12, 2013
1 parent 953c9f1 commit 61186b3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
Ansible Examples
----------------

This repository contains examples and best practises for building Ansible Playbooks.
This repository contains examples and best practices for building Ansible Playbooks.

32 changes: 13 additions & 19 deletions lamp_haproxy/README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,37 @@
Lamp Stack + LoadBalancer(haproxy) + add/remove nodes from cluster + Serial Rolling update of webserserver
Lamp Stack + load balancer(haproxy) + add/remove nodes from cluster + Serial Rolling update of webserserver
----------------------------------------------------------------------------------------------------------

This example is an extension of the simple lamp deployment, In this example we deploy a lampstack with a LoadBalancer in front.
This also has the capablity to add/remove nodes from the deployment. It also includes examples to do a rolling update of a stack
This also has the capability to add/remove nodes from the deployment. It also includes examples to do a rolling update of a stack
without affecting the service.

###Setup Entire Site.
***Setup Entire Site.
Firstly we setup the entire stack, configure the 'hosts' inventory file to include the names of your hosts on which the stack would be deployed.

[webservers]
web3
web2
[dbservers]
web3
[lbservers]
web2

After which we execute the following command to deploy the whole site.

lbserver
After which we execute the following command to deploy the site.
ansible-playbook -i hosts site.yml

The deployment can be verified by accessing the webpage." lynx http://<ip-of-lb>:8888. multiple access should land you up in diffrent webservers.
The deployment can be verified by accessing the webpage." lynx http://<ip-of-lb>:8888. multiple access should land you up in different webservers.

###Remove a node from the cluster.
***Remove a node from the cluster.
Removal of a node from the cluster would be as simple as executing the following command:
ansible-playbook -i hosts playbooks/remove_webservers.yml --limit=web2

ansible-playbook -i hosts roles/remove_webservers.yml --limit=web2

###Adding a node to the cluster.
Adding a node to the cluster can be done by executing the following command:

ansible-playbook -i hosts roles/add_webservers.yml --limit=web2
***Adding a node to the cluster.
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 of the entire site or a single hosts
***Rolling update of the entire site or a single hosts
Rolling updates are the preffered way to do an update as this wont affect the end users, In this example the hosts are updated in serial fashion, which means
that only one server would be updated at one time, this behaviour can be changed by setting the 'serial' keyword in webservers.yml file.
Once the code has been updated in the repository which can be defined in the group_vars/all file, execute the following command:

ansible-playbook -i hosts roles/rolling_update.yml
ansible-playbook -i hosts playbooks/rolling_update.yml



Expand Down
2 changes: 1 addition & 1 deletion lamp_haproxy/roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
tags: ntp

- name: Configure ntp file
template: src=common/templates/ntp.conf.j2 dest=/etc/ntp.conf
template: src=../roles/common/templates/ntp.conf.j2 dest=/etc/ntp.conf
tags: ntp
notify: restart ntp

Expand Down
6 changes: 3 additions & 3 deletions lamp_haproxy/site.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
#This Playbook deploys the whole application stack in this site.

- include: roles/db.yml
- include: roles/web.yml
- include: roles/haproxy.yml
- include: playbooks/db.yml
- include: playbooks/web.yml
- include: playbooks/haproxy.yml

0 comments on commit 61186b3

Please sign in to comment.