2015-08-11 15:22:58 +07:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: MYSQL_VARIABLES | Set read only
|
|
|
|
mysql_variables: variable=read_only value=ON
|
|
|
|
when: mysql_slave_readonly
|
|
|
|
|
|
|
|
- name: TEMPLATE | Deploy slave configuration
|
2016-02-12 15:37:29 +07:00
|
|
|
template: >
|
|
|
|
src=etc/mysql/conf.d/51-slave.cnf.j2
|
|
|
|
dest=/etc/mysql/conf.d/51-slave.cnf
|
2015-08-11 15:22:58 +07:00
|
|
|
notify: restart mysql
|
|
|
|
|
|
|
|
- name: MYSQL_REPLICATION | Get slave status
|
|
|
|
mysql_replication: mode=getslave
|
|
|
|
ignore_errors: yes
|
|
|
|
register: slave_status
|
|
|
|
|
2017-06-28 21:15:44 +07:00
|
|
|
- name: INCLUDE | Transfert /etc/mysql/debian.cnf from master
|
|
|
|
include: slave/ssh.yml
|
|
|
|
when: mysql_slave_replicate_mysqldb or ((slave_status.failed is defined or not slave_status.Is_Slave) and mysql_slave_import_data)
|
|
|
|
|
2015-08-11 15:22:58 +07:00
|
|
|
- name: INCLUDE | Import data
|
|
|
|
include: slave/import_data.yml
|
2017-06-28 21:15:44 +07:00
|
|
|
when: (slave_status.failed is defined or not slave_status.Is_Slave) and mysql_slave_import_data
|
2015-08-11 15:22:58 +07:00
|
|
|
|
|
|
|
- name: INCLUDE | Configure replication
|
|
|
|
include: slave/replication.yml
|
2017-06-28 21:15:44 +07:00
|
|
|
when: (slave_status.failed is defined or not slave_status.Is_Slave) or mysql_slave_force_setup
|
2015-08-11 15:22:58 +07:00
|
|
|
|
|
|
|
- name: INCLUDE | Transfert /etc/mysql/debian.cnf from master
|
|
|
|
include: slave/debiancnf.yml
|
|
|
|
when: mysql_slave_replicate_mysqldb
|
|
|
|
|
|
|
|
- name: MYSQL_REPLICATION | Get slave status
|
|
|
|
mysql_replication: mode=getslave
|
|
|
|
ignore_errors: yes
|
|
|
|
register: slave_status
|
|
|
|
|
|
|
|
- name: Configure MariaDB GTID
|
|
|
|
include: slave/mariadb_gtid.yml
|
|
|
|
when: >
|
|
|
|
mysql_vendor == 'mariadb' and
|
|
|
|
slave_status.Using_Gtid == 'No' and
|
2015-08-11 16:26:56 +07:00
|
|
|
mysql_gtid
|