From 506fd6b341dea7890f1291c85292fc6378187a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavi=20Lle=C3=B3=20Tom=C3=A1s?= Date: Wed, 11 Dec 2024 10:54:04 +0100 Subject: [PATCH] Refs #8140: MariaDB Server Deploy - Role WIP --- roles/services/handlers/main.yml | 3 +++ roles/services/tasks/mariadb.yml | 46 +++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/roles/services/handlers/main.yml b/roles/services/handlers/main.yml index 1769d19..c5b90a5 100644 --- a/roles/services/handlers/main.yml +++ b/roles/services/handlers/main.yml @@ -5,4 +5,7 @@ - name: restart-mariadb systemd: name: mariadb +- name: reload systemd + command: + cmd: systemctl daemon-reload diff --git a/roles/services/tasks/mariadb.yml b/roles/services/tasks/mariadb.yml index 88f2d1f..9ee1c88 100644 --- a/roles/services/tasks/mariadb.yml +++ b/roles/services/tasks/mariadb.yml @@ -3,6 +3,31 @@ name: mariadb-server state: present #install_recommends: no + +- name: Ensure log directory exists /var/log/mysql + file: + path: /var/log/mysql + state: directory + owner: mysql + group: adm + mode: u=rwx,g=rxs,o= + +- name: Ensure mysqlbin directory exists /mnt/mysqlbin + file: + path: /mnt/mysqlbin + state: directory + owner: root + group: root + mode: u=rwx,g=rx,o=rx + +- name: Ensure mysqltmp directory exists /mnt/mysqltmp with sticky bit + file: + path: /mnt/mysqltmp + state: directory + mode: u=rwx,g=rwx,o=rwxt + owner: root + group: root + - name: Set MariaDB custom configuration copy: src: "{{ item }}" @@ -13,6 +38,7 @@ with_fileglob: - "files/z9*.cnf" notify: restart-mariadb + - name: Ensure mariadb service override directory exists file: path: /etc/systemd/system/mariadb.service.d @@ -20,6 +46,7 @@ owner: root group: root mode: u=rwx,g=rx,o=rx + - name: Set MariaDB custom service.d override.conf copy: src: mariadb_override.conf @@ -27,7 +54,8 @@ owner: root group: root mode: u=rw,g=r,o=r - notify: restart-mariadb + notify: reload systemd + - name: Ensure scripts root directory exists file: path: /root/scripts @@ -35,6 +63,7 @@ owner: root group: root mode: u=rwx,g=rx,o=rx + - name: Set MariaDB custom root scripts copy: src: "{{ item }}" @@ -44,7 +73,7 @@ mode: u=rwx,g=rx,o=rx with_fileglob: - "files/scripts/*.sh" - notify: restart-mariadb + - name: Set MariaDB README root script copy: src: files/scripts/README.md @@ -52,7 +81,7 @@ owner: root group: root mode: u=rw,g=r,o=r - notify: restart-mariadb + - name: Set MariaDB performance and customize root script copy: src: files/scripts/mysqltuner.pl @@ -60,15 +89,7 @@ owner: root group: root mode: u=rwx,g=rx,o=rx - notify: restart-mariadb -- name: Ensure log directory exists /var/log/mysql - file: - path: /var/log/mysql - state: directory - owner: mysql - group: adm - mode: u=rwx,g=rxs,o= - notify: restart-mariadb + - name: Set MariaDB Cron to /etc/cron.d template: src: templates/cron_mariadb @@ -76,4 +97,3 @@ owner: root group: root mode: u=rw,g=r,o=r - notify: restart-mariadb \ No newline at end of file