From 98237aab2f85565b88a808278d05b5569a0f7645 Mon Sep 17 00:00:00 2001 From: Emilien Mantel Date: Mon, 26 Aug 2024 14:47:03 +0200 Subject: [PATCH] :bug: Fix ansible mysql calls due to wokes changes... --- tasks/main.yml | 8 +++++++ tasks/replication/slave.yml | 6 ++--- tasks/replication/slave/gtid.yml | 6 ++--- tasks/replication/slave/import_data.yml | 10 ++------- tasks/replication/slave/replication.yml | 29 ------------------------- 5 files changed, 16 insertions(+), 43 deletions(-) delete mode 100644 tasks/replication/slave/replication.yml diff --git a/tasks/main.yml b/tasks/main.yml index 0310ebb..2082f1b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -35,6 +35,14 @@ - etc/mysql/mariadb.conf.d/50-mysqld_safe.cnf.j2 - etc/mysql/mariadb.conf.d/50-server.cnf.j2 +- name: FILE | Ensure log dir exists + ansible.builtin.file: + path: "{{ mariadb_slow_query_log_file | dirname }}" + state: directory + mode: 0755 + owner: mysql + group: mysql + - name: SERVICE | Restart Mariadb now one at a time (prevent bugs) throttle: 1 ansible.builtin.service: diff --git a/tasks/replication/slave.yml b/tasks/replication/slave.yml index 1c2924e..1431aea 100644 --- a/tasks/replication/slave.yml +++ b/tasks/replication/slave.yml @@ -25,11 +25,11 @@ - 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 + when: (slave_status.failed or not slave_status.Is_Replica) and mariadb_slave_import_data -- name: Configure GTID Recplication +- name: Configure GTID Replication ansible.builtin.import_tasks: slave/gtid.yml - when: slave_status.failed or not slave_status.Is_Slave or mariadb_slave_force_setup + 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: diff --git a/tasks/replication/slave/gtid.yml b/tasks/replication/slave/gtid.yml index 653fd07..9e8f36c 100644 --- a/tasks/replication/slave/gtid.yml +++ b/tasks/replication/slave/gtid.yml @@ -2,12 +2,12 @@ - name: MYSQL_REPLICATION | Stop slave community.mysql.mysql_replication: - mode: stopslave + mode: stopreplica login_unix_socket: "{{ mariadb_socket }}" - name: MYSQL_REPLICATION | Configure master host community.mysql.mysql_replication: - mode: changemaster + mode: changeprimary master_host: "{{ mariadb_replication_host }}" master_port: "{{ mariadb_replication_port }}" master_user: "{{ mariadb_replication_user }}" @@ -22,5 +22,5 @@ - name: MYSQL_REPLICATION | Start slave community.mysql.mysql_replication: - mode: startslave + mode: startreplica login_unix_socket: "{{ mariadb_socket }}" diff --git a/tasks/replication/slave/import_data.yml b/tasks/replication/slave/import_data.yml index 7c22a33..b4f47b0 100644 --- a/tasks/replication/slave/import_data.yml +++ b/tasks/replication/slave/import_data.yml @@ -56,8 +56,8 @@ name: "{{ mariadb_service_name }}" state: stopped -- name: COMMAND | Sync backup to slave - TODO remove vagrant as static user (see why mariadb_backup_user is not working) - ansible.builtin.command: "sudo -E rsync --rsync-path='sudo rsync' -a -e 'ssh -o StrictHostKeyChecking=no' {{ mariadb_backup_user }}@{{ mariadb_slave_import_from }}:{{ mariadb_backup_dir }}/ {{ mariadb_datadir }}/" +- name: COMMAND | Sync backup to slave + ansible.builtin.command: "sudo -E rsync --rsync-path='sudo rsync' --delete -a -e 'ssh -o StrictHostKeyChecking=no' {{ mariadb_backup_user }}@{{ mariadb_slave_import_from }}:{{ mariadb_backup_dir }}/ {{ mariadb_datadir }}/" become: false tags: - skip_ansible_lint @@ -71,12 +71,6 @@ group: mysql recurse: true -- name: SHELL | Remove InnoDB redo logs - ansible.builtin.shell: "rm -f {{ mariadb_datadir }}/ib_logfile*" - args: - removes: "{{ mariadb_datadir }}/ib_logfile0" - warn: false - - name: SERVICE | Start MariaDB ansible.builtin.service: name: "{{ mariadb_service_name }}" diff --git a/tasks/replication/slave/replication.yml b/tasks/replication/slave/replication.yml deleted file mode 100644 index 0295952..0000000 --- a/tasks/replication/slave/replication.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -- name: MYSQL_REPLICATION | Stop slave - community.mysql.mysql_replication: - mode: stopslave - login_unix_socket: "{{ mariadb_socket }}" - -- name: MYSQL_REPLICATION | Configure master host - community.mysql.mysql_replication: - mode: changemaster - master_host: "{{ mariadb_replication_host }}" - master_port: "{{ mariadb_replication_port }}" - master_user: "{{ mariadb_replication_user }}" - master_password: "{{ mariadb_replication_password }}" - login_unix_socket: "{{ mariadb_socket }}" - no_log: "{{ not mariadb_debug_role }}" - -- name: MYSQL_REPLICATION | Change master - community.mysql.mysql_replication: - mode: changemaster - master_log_file: "{{ mariadb_master_log_file }}" - master_log_pos: "{{ mariadb_master_log_pos }}" - login_unix_socket: "{{ mariadb_socket }}" - when: mariadb_master_log_file is defined and mariadb_master_log_pos is defined - -- name: MYSQL_REPLICATION | Start slave - community.mysql.mysql_replication: - mode: startslave - login_unix_socket: "{{ mariadb_socket }}"