forked from RaymiiOrg/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Remy
committed
Jul 20, 2014
1 parent
055fbc6
commit 9cc0deb
Showing
18 changed files
with
726 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
header('Location: site/'); | ||
exit; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
|
||
- name: restart nginx | ||
service: | ||
name: nginx | ||
state: restarted | ||
enabled: yes | ||
|
||
- name: restart keepalived | ||
service: | ||
name: keepalived | ||
state: restarted | ||
enabled: yes | ||
|
||
- name: restart mysql | ||
service: | ||
name: mysql | ||
state: restarted | ||
enabled: yes | ||
|
||
- name: restart apache2 | ||
service: | ||
name: apache2 | ||
state: restarted | ||
enabled: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
- name: Create Instances | ||
hosts: 127.0.0.1 | ||
connection: local | ||
vars_files: | ||
- "vars/main.yml" | ||
tasks: | ||
- include: tasks/create-instances.yml | ||
|
||
# Both lbs group and app group but only execute on lbs group. Otherwise | ||
# facts about app group are not gathered and config fails | ||
- name: Configure LoadBalancers | ||
hosts: lbs:app | ||
vars_files: | ||
- "vars/main.yml" | ||
user: root | ||
tasks: | ||
- include: tasks/configure-lbs.yml | ||
when: '"{{ inventory_hostname }}" in "{{ groups.lbs }}"' | ||
- include: tasks/keepalived.yml | ||
when: '"{{ inventory_hostname }}" in "{{ groups.lbs }}"' | ||
handlers: | ||
- include: handlers/main.yml | ||
|
||
- name: Configure Databases | ||
hosts: dbs | ||
vars_files: | ||
- "vars/main.yml" | ||
user: root | ||
tasks: | ||
- include: tasks/configure-dbs.yml | ||
- include: tasks/keepalived.yml | ||
handlers: | ||
- include: handlers/main.yml | ||
|
||
- name: Configure App Server | ||
hosts: app | ||
vars_files: | ||
- "vars/main.yml" | ||
user: root | ||
tasks: | ||
- include: tasks/configure-gluster-app.yml | ||
- include: tasks/configure-app.yml | ||
handlers: | ||
- include: handlers/main.yml | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
- apt: | ||
name="{{ item }}" | ||
state=latest | ||
update_cache=yes | ||
with_items: | ||
- php5-mysql | ||
- python-pip | ||
- php5 | ||
- libapache2-mod-php5 | ||
- php5-mcrypt | ||
- vim | ||
- git | ||
- ntp | ||
|
||
- git: | ||
repo: https://github.com/WordPress/WordPress.git | ||
dest: /var/www/html/site | ||
force: yes | ||
update: no | ||
when: '"{{ inventory_hostname }}" == "{{ groups.app[0] }}"' | ||
|
||
|
||
- file: | ||
dest: /var/www/html/index.html | ||
state: absent | ||
|
||
- template: | ||
src: wp-config.php.j2 | ||
dest: /var/www/html/site/wp-config.php | ||
when: '"{{ inventory_hostname }}" == "{{ groups.app[0] }}"' | ||
|
||
|
||
- copy: | ||
src: index.php | ||
dest: /var/www/html/index.php | ||
when: '"{{ inventory_hostname }}" == "{{ groups.app[0] }}"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
- apt: | ||
name="{{ item }}" | ||
state=latest | ||
update_cache=yes | ||
with_items: | ||
- mysql-server | ||
- python-mysqldb | ||
- vim | ||
- git | ||
- ntp | ||
|
||
- template: | ||
src: my.cnf.j2 | ||
dest: /etc/mysql/my.cnf | ||
notify: | ||
- restart mysql | ||
|
||
- fetch: | ||
src: /etc/mysql/debian.cnf | ||
flat: yes | ||
dest: "/tmp/my.cnf.{{ ansible_hostname }}" | ||
|
||
- copy: | ||
src: "/tmp/my.cnf.{{ ansible_hostname }}" | ||
dest: /root/.my.cnf | ||
|
||
- mysql_user: | ||
user: "" | ||
state: "absent" | ||
|
||
- mysql_user: | ||
name: "{{ mysql_user }}" | ||
password: "{{ mysql_password }}" | ||
host: "%" | ||
priv: '{{ mysql_user }}.*:ALL' | ||
state: present | ||
|
||
- mysql_db: | ||
name: "{{ mysql_user }}" | ||
state: present | ||
|
||
- mysql_user: | ||
name: "replicator" | ||
host: "%" | ||
password: "{{ mysql_password }}" | ||
priv: "*.*:REPLICATION SLAVE" | ||
state: present | ||
notify: | ||
- restart mysql | ||
|
||
- stat: path=/etc/mysql/ansible.repl | ||
register: check_sql_path | ||
|
||
- mysql_replication: | ||
mode: changemaster | ||
master_host: "{{ groups.dbs[1] }}" | ||
master_user: replicator | ||
master_password: "{{ mysql_password }}" | ||
when: check_sql_path.stat.exists == false and '{{ inventory_hostname }}' == '{{ groups.dbs[0] }}' | ||
register: sqlresult0 | ||
notify: | ||
- restart mysql | ||
|
||
- mysql_replication: | ||
mode: changemaster | ||
master_host: "{{ groups.dbs[0] }}" | ||
master_user: replicator | ||
master_password: "{{ mysql_password }}" | ||
when: check_sql_path.stat.exists == false and '{{ inventory_hostname }}' == '{{ groups.dbs[1] }}' | ||
register: sqlresult1 | ||
notify: | ||
- restart mysql | ||
|
||
- command: touch /etc/mysql/repl.ansible | ||
when: check_sql_path.stat.exists == false and '{{ inventory_hostname }}' == '{{ groups.dbs[1] }}' | ||
|
||
- command: touch /etc/mysql/repl.ansible | ||
when: check_sql_path.stat.exists == false and '{{ inventory_hostname }}' == '{{ groups.dbs[1] }}' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
# boot bug in standard 14.04 packages: https://bugs.launchpad.net/ubuntu/+source/glusterfs/+bug/1268064 | ||
- apt_repository: | ||
repo: 'ppa:semiosis/ubuntu-glusterfs-3.4' | ||
state: present | ||
update_cache: yes | ||
|
||
- apt: | ||
name: "{{ item }}" | ||
state: installed | ||
update_cache: yes | ||
with_items: | ||
- glusterfs-server | ||
- glusterfs-client | ||
|
||
- file: | ||
path: "{{ gluster_brick_dir }}" | ||
state: directory | ||
|
||
- shell: "gluster peer probe {{ item }}" | ||
with_items: | ||
- "{{ groups.app }}" | ||
|
||
- shell: 'echo {{ groups.app }} | sed -e "s/\]//g" -e "s/, u/, /g" -e "s/\[u//g" -e "s%,%:{{ gluster_brick_dir }} %g; s%$%:{{ gluster_brick_dir }}%"' | ||
register: gluster_bricks | ||
connection: local | ||
|
||
- shell: 'gluster volume info {{ gluster_volume }} || | ||
gluster volume create {{ gluster_volume }} transport tcp replica 2 | ||
{{ gluster_bricks.stdout }} force' | ||
when: '"{{ inventory_hostname }}" == "{{ groups.app[0] }}"' | ||
|
||
- wait_for: | ||
delay: 15 | ||
timeout: 15 | ||
|
||
- shell: 'gluster volume info {{ gluster_volume }} | grep "Status: Started" || | ||
gluster volume start {{ gluster_volume }}' | ||
|
||
- file: | ||
path: "/var/www/html" | ||
state: directory | ||
|
||
- mount: | ||
name: /var/www/html | ||
fstype: glusterfs | ||
src: "{{ groups.app[0] }}:{{ gluster_volume }}" | ||
state: mounted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
- apt_repository: | ||
repo: 'ppa:nginx/stable' | ||
state: present | ||
update_cache: yes | ||
|
||
- apt: | ||
name: "{{ item }}" | ||
state: latest | ||
update_cache: yes | ||
with_items: | ||
- nginx | ||
- vim | ||
- git | ||
- ntp | ||
|
||
- file: | ||
dest: /var/cache/nginx | ||
state: directory | ||
owner: www-data | ||
|
||
- template: | ||
src: nginx-lb.conf.j2 | ||
dest: /etc/nginx/sites-available/lbs.conf | ||
notify: | ||
- restart nginx | ||
|
||
- file: | ||
src: /etc/nginx/sites-available/lbs.conf | ||
dest: /etc/nginx/sites-enabled/lbs.conf | ||
state: link | ||
notify: | ||
- restart nginx | ||
|
||
- file: | ||
dest: /etc/nginx/sites-enabled/default | ||
state: absent | ||
notify: | ||
- restart nginx | ||
|
||
|
Oops, something went wrong.