diff --git a/roles/db/tasks/install.yml b/roles/db/tasks/install.yml index 06bed17..e9e5ebf 100644 --- a/roles/db/tasks/install.yml +++ b/roles/db/tasks/install.yml @@ -24,6 +24,26 @@ - name: Replace config file template: src=../roles/db/templates/my.cnf.j2 dest=/etc/mysql/my.cnf +- name: Create wrestlingtourney database + action: shell mysql -e "CREATE DATABASE wrestlingtourney;" + ignore_errors: yes + +- name: Set up haproxy_check user + action: shell mysql -e "CREATE USER 'haproxy_check'@'%'; FLUSH PRIVILEGES;" + ignore_errors: yes + +- name: Set up user for wrestlingtourney + action: shell mysql -e "CREATE USER 'heroku_jcw'@'%' IDENTIFIED BY '{{ heroku_jcw_password }}';GRANT ALL PRIVILEGES ON wrestlingtourney.* TO 'heroku_jcw'@'%'; FLUSH PRIVILEGES;" + ignore_errors: yes + +- name: set mysql root password + action: shell mysql -e "UPDATE mysql.user SET password=PASSWORD('{{ root_mysql_password }}') where user='root'; FLUSH PRIVILEGES;" + ignore_errors: yes + - name: Stop mysql service service: name=mysql state=stopped +- name: Replace debian config file + template: src=../roles/db/templates/debian.cnf.j2 dest=/etc/mysql/debian.cnf + + diff --git a/roles/db/tasks/startcluster.yml b/roles/db/tasks/startcluster.yml index f4e3e75..9cc24b8 100644 --- a/roles/db/tasks/startcluster.yml +++ b/roles/db/tasks/startcluster.yml @@ -5,16 +5,4 @@ - 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 up haproxy_check user - action: shell mysql -e "CREATE USER 'haproxy_check'@'%'; FLUSH PRIVILEGES;" - -- name: Set up user for wrestlingtourney - action: shell mysql -e "CREATE USER 'heroku_jcw'@'%' IDENTIFIED BY '{{ heroku_jcw_password }}';GRANT ALL PRIVILEGES ON wrestlingtourney.* TO 'heroku_jcw'@'%'; FLUSH PRIVILEGES;" - -- name: set mysql root password - action: shell mysql -e "UPDATE mysql.user SET password=PASSWORD('{{ root_mysql_password }}') where user='root'; FLUSH PRIVILEGES;" - diff --git a/roles/db/templates/debian.cnf.j2 b/roles/db/templates/debian.cnf.j2 new file mode 100644 index 0000000..5459b8b --- /dev/null +++ b/roles/db/templates/debian.cnf.j2 @@ -0,0 +1,13 @@ +# Automatically generated for Debian scripts. DO NOT TOUCH! +[client] +host = localhost +user = root +password = {{ root_mysql_password }} +socket = /var/run/mysqld/mysqld.sock +[mysql_upgrade] +host = localhost +user = root +password = {{ root_mysql_password }} +socket = /var/run/mysqld/mysqld.sock +basedir = /usr +