diff --git a/roles/services/tasks/mariadb.yml b/roles/services/tasks/mariadb.yml index b831a5c..a10f5ea 100644 --- a/roles/services/tasks/mariadb.yml +++ b/roles/services/tasks/mariadb.yml @@ -71,7 +71,7 @@ # mode: u=rw,g=r,o=r - name: Insert MySQL certificates - #no_log: true + no_log: true copy: content: "{{ item.content }}" dest: "{{ item.dest }}" @@ -104,7 +104,7 @@ - /mnt/local-backup Make sure they are correctly configured and accessible. -- when: production is false +- when: production is false or production is not defined block: - name: Set MariaDB custom configuration Test-DB-DEV @@ -157,3 +157,26 @@ owner: root group: root mode: u=rw,g=,o= + +- name: Check if /var/lib/mysql/ exists + stat: + path: /var/lib/mysql/ + register: mysql_dir + + +- when: mysql_dir.stat.exists + block: + + - name: Sync MySQL data directory + synchronize: + src: /var/lib/mysql/ + dest: /mnt/mysqldata/mysql/ + archive: true + compress: true + recursive: true + delegate_to: "{{ inventory_hostname }}" + + - name: Remove old MySQL data after sync + file: + path: /var/lib/mysql/ + state: absent