From d2a14aeb821f41c69702bec09f00a6dd9bccfddb Mon Sep 17 00:00:00 2001 From: gutleib Date: Sun, 24 Nov 2024 22:05:46 +0300 Subject: [PATCH 1/2] Include custom_datadir_populate in tasks/main.yml --- tasks/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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: From 0ea498d7966688d174f2c41a5b913e1dfe40259e Mon Sep 17 00:00:00 2001 From: gutleib Date: Sun, 24 Nov 2024 22:07:22 +0300 Subject: [PATCH 2/2] Create custom_datadir_populate.yml --- tasks/custom_datadir_populate.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tasks/custom_datadir_populate.yml 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