ansible-mysql/tasks/replication/slave.yml

40 lines
1.2 KiB
YAML
Raw Permalink Normal View History

---
- name: MYSQL_VARIABLES | Set read only
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
- 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
2024-08-26 15:12:09 +07:00
notify: Restart mariadb
- name: MYSQL_REPLICATION | Get slave status
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 }}"
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_Replica) and mariadb_slave_import_data
- name: Configure GTID Replication
ansible.builtin.import_tasks: slave/gtid.yml
when: slave_status.failed or not slave_status.Is_Replica or mariadb_slave_force_setup
- name: MYSQL_REPLICATION | Get slave status
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 }}"
ignore_errors: true
register: slave_status