2015-07-12 15:42:46 +07:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: STAT | Check if mysql exists
|
|
|
|
stat: path=/etc/init.d/mysql
|
|
|
|
register: mysql_exists
|
|
|
|
changed_when: false
|
|
|
|
|
2015-07-12 17:47:44 +07:00
|
|
|
- name: INCLUDE | Install
|
2015-08-21 14:40:44 +07:00
|
|
|
include: install/main.yml
|
2015-07-12 17:47:44 +07:00
|
|
|
|
2015-08-11 04:45:01 +07:00
|
|
|
- name: TEMPLATE | Deploy configuration
|
|
|
|
template: src=etc/mysql/my.cnf.j2 dest=/etc/mysql/my.cnf
|
2015-08-11 15:22:58 +07:00
|
|
|
register: config
|
2015-08-11 04:45:01 +07:00
|
|
|
|
|
|
|
- name: TEMPLATE | Deploy extra configuration
|
|
|
|
template: src=etc/mysql/conf.d/10-extra.cnf.j2 dest=/etc/mysql/conf.d/10-extra.cnf
|
2015-08-21 15:14:23 +07:00
|
|
|
register: extraconfig
|
|
|
|
|
|
|
|
- name: SERVICE | Restart now (prevent bugs)
|
|
|
|
service: name=mysql state=restarted
|
|
|
|
when: config.changed or extraconfig.changed
|
2015-07-12 15:42:46 +07:00
|
|
|
|
|
|
|
- name: TEMPLATE Create .my.cnf for root
|
|
|
|
template: src=root/my.cnf dest=/root/.my.cnf owner=root group=root mode=0600 backup=yes
|
|
|
|
|
2015-08-21 15:10:27 +07:00
|
|
|
- name: INCLUDE | Replication
|
|
|
|
include: replication/main.yml
|
|
|
|
when: mysql_replication_master or mysql_replication_slave
|
2015-08-08 04:34:47 +07:00
|
|
|
|
2015-07-12 15:42:46 +07:00
|
|
|
- name: INCLUDE | Secure install
|
|
|
|
include: 'secure.yml'
|
|
|
|
|
|
|
|
- name: MYSQL_DB | Create databases
|
|
|
|
mysql_db: name={{ item }} state=present
|
|
|
|
with_items: mysql_databases
|
|
|
|
|
|
|
|
- name: MYSQL_USER | Manages users...
|
2015-08-08 18:02:59 +07:00
|
|
|
mysql_user: >
|
2016-02-09 23:43:49 +07:00
|
|
|
name="{{ item.name }}"
|
|
|
|
password="{{ item.password }}"
|
|
|
|
priv="{{ item.priv }}"
|
|
|
|
host="{{ item.host | default('localhost') }}"
|
2015-08-08 18:02:59 +07:00
|
|
|
state=present
|
2015-07-12 15:42:46 +07:00
|
|
|
with_items: mysql_users
|
|
|
|
|