diff --git a/defaults/main.yml b/defaults/main.yml index 8e5b321..f02f688 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -114,6 +114,8 @@ mysql_master_log_pos: null # If true, reconfigure slave mysql_slave_force_setup: false +# Only MariaDB 10.0+ +mysql_gtid_domain_id: 1 # ------------------------------------- # Database / Users diff --git a/tasks/detect_gtid.yml b/tasks/detect_gtid.yml new file mode 100644 index 0000000..29b6c12 --- /dev/null +++ b/tasks/detect_gtid.yml @@ -0,0 +1,12 @@ +--- + +- name: MYSQL_VARIABLES | Get MySQL vendor + mysql_variables: variable=version_comment + register: vc + +- name: SET_FACT | Server can use GTID + set_fact: mysql_gtid=true + when: > + ( mysql_vendor == 'mariadb' and vc.msg[0][1] | version_compare('10.0.2', 'ge') ) or + ( vc.msg[0][1] | version_compare('5.6.5', 'ge') ) + diff --git a/tasks/main.yml b/tasks/main.yml index 0921a9a..dd7a356 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -29,6 +29,9 @@ - name: TEMPLATE Create .my.cnf for root template: src=root/my.cnf dest=/root/.my.cnf owner=root group=root mode=0600 backup=yes +- name: INCLUDE | Detect if server supports GTID + include: detect_gtid.yml + - name: INCLUDE | Replication Master include: replication_master.yml when: mysql_replication_master diff --git a/tasks/replication_slave.yml b/tasks/replication_slave.yml index 128bef6..0a4c31e 100644 --- a/tasks/replication_slave.yml +++ b/tasks/replication_slave.yml @@ -35,4 +35,4 @@ when: > mysql_vendor == 'mariadb' and slave_status.Using_Gtid == 'No' and - mysql_mysql_gtid + mysql_gtid diff --git a/templates/etc/mysql/conf.d/50-master.cnf.j2 b/templates/etc/mysql/conf.d/50-master.cnf.j2 index 4e380a7..d96069f 100644 --- a/templates/etc/mysql/conf.d/50-master.cnf.j2 +++ b/templates/etc/mysql/conf.d/50-master.cnf.j2 @@ -7,9 +7,14 @@ [mysqld] server_id={{ mysql_server_id }} -log-bin +log_bin = mysql-bin +log-bin-index = mysql-bin.index +expire_logs_days = {{ mysql_expire_logs_days }} +max_binlog_size = {{ mysql_max_binlog_size }} -# MariaDB only? -#gtid_domain_id=1 +{% if mysql_vendor == 'mariadb' and mysql_gtid %} +# MariaDB only +gtid_domain_id={{ mysql_gtid_domain_id }} +{% endif %} ; vim: set ft=dosini :