40 lines
1.2 KiB
YAML
40 lines
1.2 KiB
YAML
---
|
|
|
|
- name: MYSQL_VARIABLES | Set read only
|
|
community.mysql.mysql_variables:
|
|
variable: read_only
|
|
value: 'ON'
|
|
login_unix_socket: "{{ mariadb_socket }}"
|
|
when: mariadb_slave_readonly
|
|
|
|
- name: TEMPLATE | Deploy slave configuration
|
|
ansible.builtin.template:
|
|
src: etc/mysql/mariadb.conf.d/40-slave.cnf.j2
|
|
dest: /etc/mysql/mariadb.conf.d/40-slave.cnf
|
|
mode: 0644
|
|
owner: root
|
|
group: root
|
|
notify: Restart mariadb
|
|
|
|
- name: MYSQL_REPLICATION | Get slave status
|
|
community.mysql.mysql_replication:
|
|
mode: getreplica
|
|
login_unix_socket: "{{ mariadb_socket }}"
|
|
ignore_errors: true
|
|
register: slave_status
|
|
|
|
- name: INCLUDE | Import data
|
|
ansible.builtin.import_tasks: slave/import_data.yml
|
|
when: (slave_status.failed or not slave_status.Is_Slave) and mariadb_slave_import_data
|
|
|
|
- name: Configure GTID Recplication
|
|
ansible.builtin.import_tasks: slave/gtid.yml
|
|
when: slave_status.failed or not slave_status.Is_Slave or mariadb_slave_force_setup
|
|
|
|
- name: MYSQL_REPLICATION | Get slave status
|
|
community.mysql.mysql_replication:
|
|
mode: getreplica
|
|
login_unix_socket: "{{ mariadb_socket }}"
|
|
ignore_errors: true
|
|
register: slave_status
|