Re-organized all files and added a Vagrantfile

This commit is contained in:
2016-02-02 11:40:47 -05:00
parent dd4fd53ce7
commit 8a55e9f946
19 changed files with 157 additions and 96 deletions

View File

@@ -29,3 +29,7 @@
- name: Modify configuration file to listen on all interfaces
lineinfile: dest=/etc/mysql/my.cnf regexp="^bind-address" line="bind-address=0.0.0.0"
- name: Stop mysql service
service: name=mysql state=stop

View File

@@ -0,0 +1,27 @@
---
# This starts the galera cluster
# Check if mysql is running
- name: bootstrap by starting mysql with gcom://
action: shell /etc/init.d/mysql start --wsrep-cluster-address="gcomm://"
only_if: ${is_mysql_running.rc} > 0
- name: set mysql root password
action: shell mysql -e "UPDATE mysql.user SET password=PASSWORD('$root_mysql_password') where user='root';"
only_if: ${is_mysql_running.rc} > 0
- name: create state snapshot transfer user from anywhere
action: shell mysql -e "CREATE USER '$state_snapshot_transfer_user'@'%' IDENTIFIED BY '$state_snapshot_transfer_password';"
only_if: ${is_mysql_running.rc} > 0
- name: create state snapshot transfer user from localhost
action: shell mysql -e "CREATE USER '$state_snapshot_transfer_user'@'localhost' IDENTIFIED BY '$state_snapshot_transfer_password';"
only_if: ${is_mysql_running.rc} > 0
- name: set privileges for state snapshot transfer user
action: shell mysql -e "GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '$state_snapshot_transfer_user'@'%';"
only_if: ${is_mysql_running.rc} > 0
- name: set privileges for state snapshot transfer user and flush privileges
action: shell mysql -e "GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '$state_snapshot_transfer_user'@'localhost'; FLUSH PRIVILEGES;"
only_if: ${is_mysql_running.rc} > 0

View File

@@ -0,0 +1,6 @@
---
# This starts the mysql service
- name: Start mysql service
service: name=mysql state=start

View File

@@ -1,13 +0,0 @@
---
# This sets up the wrestlingtourney database and starts the binlogs
# https://mariadb.com/blog/devops-mariadb-part-1
# https://mariadb.com/blog/devops-mariadb-and-ansible-part-2
- name: Modify configuration file to setup server ID
lineinfile: dest=/etc/mysql/my.cnf regexp="^#server-id" line="server-id=1"
- name: Restart mysql service
service: name=mysql state=restarted
- name: Reset master binlog
command: /usr/bin/mysql -u root -e "RESET MASTER"

View File

@@ -21,7 +21,7 @@ listen mysql-cluster
mode tcp
option mysql-check user haproxy_check
balance roundrobin
{% for db_server in masterdb-internal %}
{% for db_server in db-internal %}
server {{ db_server }} {{ db_server }}:3306 check
{% endfor %}
@@ -33,20 +33,12 @@ frontend www-http
frontend www-https
bind 0.0.0.0:443 ssl crt /root/server.pem
reqadd X-Forwarded-Proto:\ https
acl host_wrestlingdev hdr(host) -i wrestlingdev.com
use_backend wrestlingdev if host_wrestlingdev
default_backend www-backend
backend www-backend
redirect scheme https if !{ ssl_fc }
errorfile 503 /root/home.html
default_backend wrestlingdev
backend wrestlingdev
redirect scheme https if !{ ssl_fc }
balance roundrobin
cookie SERVERID insert indirect nocache
{% for web_server in web-internal-ips %}
{% for web_server in web-internal %}
server {{ web_server }} {{ web_server }}:443 check cookie {{ web_server }} ssl verify none
{% endfor %}

View File

@@ -1,13 +0,0 @@
---
# This installs mariadb and galera on db nodes
# https://mariadb.com/blog/devops-mariadb-part-1
# https://mariadb.com/blog/devops-mariadb-and-ansible-part-2
- name: Modify configuration file to setup server ID
lineinfile: dest=/etc/mysql/my.cnf regexp="^#server-id" line="server-id=2"
- name: Setup replication
command: /usr/bin/mysql -uroot -e "CHANGE MASTER TO master_host='192.168.50.2', master_user='repl', master_password='{{ replication_password }}', master_use_gtid=current_pos"
- name: Restart mysql service
service: name=mysql state=restarted