2015-08-11 15:22:58 +07:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: MYSQL_VARIABLES | Set read only
|
2021-09-02 23:17:54 +07:00
|
|
|
community.mysql.mysql_variables:
|
2018-03-18 00:28:56 +07:00
|
|
|
variable: read_only
|
|
|
|
value: 'ON'
|
2022-03-04 16:56:27 +07:00
|
|
|
login_unix_socket: "{{ mariadb_socket }}"
|
2018-03-17 23:28:54 +07:00
|
|
|
when: mariadb_slave_readonly
|
2015-08-11 15:22:58 +07:00
|
|
|
|
|
|
|
- name: TEMPLATE | Deploy slave configuration
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.template:
|
2019-12-29 01:02:41 +07:00
|
|
|
src: etc/mysql/mariadb.conf.d/40-slave.cnf.j2
|
|
|
|
dest: /etc/mysql/mariadb.conf.d/40-slave.cnf
|
2021-09-02 23:17:54 +07:00
|
|
|
mode: 0644
|
|
|
|
owner: root
|
|
|
|
group: root
|
2024-08-26 15:12:09 +07:00
|
|
|
notify: Restart mariadb
|
2015-08-11 15:22:58 +07:00
|
|
|
|
|
|
|
- name: MYSQL_REPLICATION | Get slave status
|
2021-09-02 23:17:54 +07:00
|
|
|
community.mysql.mysql_replication:
|
2024-08-26 15:12:09 +07:00
|
|
|
mode: getreplica
|
2022-03-04 16:56:27 +07:00
|
|
|
login_unix_socket: "{{ mariadb_socket }}"
|
2021-09-02 23:17:54 +07:00
|
|
|
ignore_errors: true
|
2015-08-11 15:22:58 +07:00
|
|
|
register: slave_status
|
|
|
|
|
|
|
|
- name: INCLUDE | Import data
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.import_tasks: slave/import_data.yml
|
2019-12-29 01:02:41 +07:00
|
|
|
when: (slave_status.failed or not slave_status.Is_Slave) and mariadb_slave_import_data
|
2015-08-11 15:22:58 +07:00
|
|
|
|
2019-12-29 01:02:41 +07:00
|
|
|
- name: Configure GTID Recplication
|
2021-09-02 23:17:54 +07:00
|
|
|
ansible.builtin.import_tasks: slave/gtid.yml
|
2019-12-29 01:02:41 +07:00
|
|
|
when: slave_status.failed or not slave_status.Is_Slave or mariadb_slave_force_setup
|
2015-08-11 15:22:58 +07:00
|
|
|
|
|
|
|
- name: MYSQL_REPLICATION | Get slave status
|
2021-09-02 23:17:54 +07:00
|
|
|
community.mysql.mysql_replication:
|
2024-08-26 15:12:09 +07:00
|
|
|
mode: getreplica
|
2022-03-04 16:56:27 +07:00
|
|
|
login_unix_socket: "{{ mariadb_socket }}"
|
2021-09-02 23:17:54 +07:00
|
|
|
ignore_errors: true
|
2015-08-11 15:22:58 +07:00
|
|
|
register: slave_status
|