From ba765059fc32488a4f154d863a3e747873f3ae31 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Wed, 3 Feb 2016 00:01:26 -0500 Subject: [PATCH] A lot of changes based on dry run results --- deploy-site.sh | 4 ++-- group_vars/all | 3 +++ roles/common/tasks/main.yml | 3 --- roles/db/tasks/install.yml | 4 ++-- roles/db/tasks/startcluster.yml | 13 +++++++------ roles/db/tasks/startmysql.yml | 2 +- roles/proxy/tasks/main.yml | 2 +- roles/proxy/templates/haproxy.cfg.j2 | 4 ++-- roles/rails/tasks/vars.yml | 5 +++++ site.yml | 4 ++++ 10 files changed, 27 insertions(+), 17 deletions(-) diff --git a/deploy-site.sh b/deploy-site.sh index 56781ef..410b90c 100644 --- a/deploy-site.sh +++ b/deploy-site.sh @@ -3,8 +3,8 @@ if [ -z ${WRESTLINGDEV_DB_NAME} ]; then exit fi -if [ -z ${WRESTLINGDEV_DB_USER} ]; then - echo "WRESTLINGDEV_DB_USER not set" +if [ -z ${WRESTLINGDEV_DB_USR} ]; then + echo "WRESTLINGDEV_DB_USR not set" exit fi diff --git a/group_vars/all b/group_vars/all index d53976a..7795f9f 100644 --- a/group_vars/all +++ b/group_vars/all @@ -4,3 +4,6 @@ repository: https://github.com/jcwimer/wrestlingApp.git root_mysql_password: something heroku_jcw_password: something +proxy_stats_uri: /someplace +proxy_stats_user: something +proxy_stats_pass: something diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 22a1cec..1850f51 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -19,9 +19,6 @@ - name: Install git apt: name=git state=present -- name: Install tmux - apt: name=tmux state=prsent - - name: Install rsync apt: name=rsync state=present diff --git a/roles/db/tasks/install.yml b/roles/db/tasks/install.yml index 8a0f3c8..06bed17 100644 --- a/roles/db/tasks/install.yml +++ b/roles/db/tasks/install.yml @@ -22,8 +22,8 @@ apt: name=python-mysqldb state=installed - name: Replace config file - template: src=my.cnf.j2 dest=/etc/mysql/my.cnf + template: src=../roles/db/templates/my.cnf.j2 dest=/etc/mysql/my.cnf - name: Stop mysql service - service: name=mysql state=stop + service: name=mysql state=stopped diff --git a/roles/db/tasks/startcluster.yml b/roles/db/tasks/startcluster.yml index 8d2cc96..1879edb 100644 --- a/roles/db/tasks/startcluster.yml +++ b/roles/db/tasks/startcluster.yml @@ -2,21 +2,22 @@ # 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: is mysql running? + action: shell service mysql status + register: is_mysql_running + ignore_errors: true + +- name: bootstrap by starting mysql with new cluster + action: shell service mysql start --wsrep-new-cluster - name: Create wrestlingtourney database action: shell mysql -e "CREATE DATABASE wrestlingtourney;" - name: set mysql root password action: shell mysql -e "UPDATE mysql.user SET password=PASSWORD('$root_mysql_password') where user='root'; FLUSH PRIVILEGES;" - only_if: $(is_mysql_running.rc} > 0 - name: Set up haproxy_check user action: shell mysql -u root -p -e "INSERT INTO mysql.user (Host,User) values ('%','haproxy_check'); FLUSH PRIVILEGES;" - only_if: $(is_mysql_running.rc} > 0 - name: Set up user for wrestlingtourney action: shell mysql -u root -p -e "CREATE USER 'heroku_jcw'@'%' IDENTIFIED BY '($heroku_jcw_password)';GRANT ALL PRIVILEGES ON wrestlingtourney.* TO 'heroku_jcw'@'%'; FLUSH PRIVILEGES;" - only_if: $(is_mysql_running.rc} > 0 diff --git a/roles/db/tasks/startmysql.yml b/roles/db/tasks/startmysql.yml index 4df566c..4a4a594 100644 --- a/roles/db/tasks/startmysql.yml +++ b/roles/db/tasks/startmysql.yml @@ -2,5 +2,5 @@ # This starts the mysql service - name: Start mysql service - service: name=mysql state=start + service: name=mysql state=started diff --git a/roles/proxy/tasks/main.yml b/roles/proxy/tasks/main.yml index 9c037b5..37b1261 100644 --- a/roles/proxy/tasks/main.yml +++ b/roles/proxy/tasks/main.yml @@ -8,7 +8,7 @@ apt: name=haproxy state=present - name: Create haproxy config file - template: src=haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg + template: src=../roles/proxy/templates/haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg - name: Enable init script replace: dest='/etc/default/haproxy' diff --git a/roles/proxy/templates/haproxy.cfg.j2 b/roles/proxy/templates/haproxy.cfg.j2 index e46c9c8..75bcd64 100644 --- a/roles/proxy/templates/haproxy.cfg.j2 +++ b/roles/proxy/templates/haproxy.cfg.j2 @@ -21,7 +21,7 @@ listen mysql-cluster mode tcp option mysql-check user haproxy_check balance roundrobin - {% for db_server in db %} + {% for db_server in groups['db'] %} server {{ hostvars[db_server]['ansible_eth1']['ipv4']['address'] }} {{ hostvars[db_server]['ansible_eth1']['ipv4']['address'] }}:3306 check {% endfor %} @@ -39,6 +39,6 @@ backend wrestlingdev redirect scheme https if !{ ssl_fc } balance roundrobin cookie SERVERID insert indirect nocache - {% for web_server in web %} + {% for web_server in groups['web'] %} server {{ hostvars[web_server]['ansible_eth1']['ipv4']['address'] }} {{ hostvars[web_server]['ansible_eth1']['ipv4']['address'] }}:443 check cookie {{ hostvars[web_server]['ansible_eth1']['ipv4']['address'] }} ssl verify none {% endfor %} diff --git a/roles/rails/tasks/vars.yml b/roles/rails/tasks/vars.yml index cc22d6e..9687946 100644 --- a/roles/rails/tasks/vars.yml +++ b/roles/rails/tasks/vars.yml @@ -17,6 +17,11 @@ - name: Set db password shell: echo export WRESTLINGDEV_DB_PWD={{ lookup('env', 'WRESTLINGDEV_DB_PWD') }} >> /var/www/html/prod.env + +- name: Set db username + shell: echo export WRESTLINGDEV_DB_USR={{ lookup('env', 'WRESTLINGDEV_DB_USR') }} >> /var/www/html/prod.env + + - name: Set db host shell: echo export WRESTLINGDEV_DB_HOST={{ lookup('env', 'WRESTLINGDEV_DB_HOST') }} >> /var/www/html/prod.env diff --git a/site.yml b/site.yml index ae0a024..ebe5e92 100644 --- a/site.yml +++ b/site.yml @@ -1,6 +1,10 @@ --- # This playbook deploys the whole application stack for wrestlingdev # +- name: Gather facts for all + hosts: all + remote_user: root + gather_facts: true - include: playbooks/galeradb.yml - include: playbooks/proxy.yml