From b8aa13a5d128f2deb24ff105c89def541d4041e1 Mon Sep 17 00:00:00 2001
From: Tommaso Piccioli <tommaso.piccioli@isti.cnr.it>
Date: Thu, 14 Oct 2021 17:39:36 +0200
Subject: [PATCH] Update 'tasks/mysql-conf.yml'

---
 tasks/mysql-conf.yml | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tasks/mysql-conf.yml b/tasks/mysql-conf.yml
index 68736a4..33f639b 100644
--- a/tasks/mysql-conf.yml
+++ b/tasks/mysql-conf.yml
@@ -12,6 +12,13 @@
   - name: Create the data directory
     file: dest={{ mysql_data_dir }} state=directory owner=mysql group=mysql mode=0700
     
+  - name: Copy data to the new directory
+    synchronize:
+      src: /var/lib/mysql
+      dest: {{ mysql_data_dir }}
+    delegate_to: "{{ inventory_hostname }}"
+    when: my_data_dir.stat.isdir is not defined
+
   - name: Create the log directory
     file: dest={{ mysql_log_dir }} state=directory owner=mysql group=adm mode=1750
   
@@ -29,7 +36,7 @@
     notify: Restart mysql
   
   - name: Start the mysql service with the new the data directory
-    service: name=mysql state=stopped
+    service: name=mysql state=started
     when: my_data_dir.stat.isdir is not defined
 
   when: mysql_enabled | bool