diff --git a/tasks/custom_datadir_populate.yml b/tasks/custom_datadir_populate.yml new file mode 100644 index 0000000..1f7a037 --- /dev/null +++ b/tasks/custom_datadir_populate.yml @@ -0,0 +1,22 @@ +--- +- name: ensure database directory exists + ansible.builtin.file: + path: "{{ mariadb_mysql_settings.datadir }}" + state: directory + owner: mysql + group: mysql + mode: '0755' + +- name: check if datadir folder is empty before proceeding + find: + paths: '/var/lib/mysql/' + register: filesFoundInGaleraDatadir + +- name: copy default files from default folder to custom datadir (if needed) + ansible.builtin.copy: + src: /var/lib/mysql/* + dest: "{{ mariadb_mysql_settings.datadir }}" + owner: mysql + group: mysql + mode: '0755' + when: filesFoundInGaleraDatadir.matched == 0 diff --git a/tasks/main.yml b/tasks/main.yml index d80b4b3..d41f174 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -29,7 +29,11 @@ - ansible.builtin.import_tasks: system_performance_tuning.yml tags: - config - + +- ansible.builtin.import_tasks: custom_datadir_populate.yml + tags: + - always + - name: flush handlers before continuing meta: flush_handlers tags: