Skip to content

Commit

Permalink
Initialize Custom Data Directory
Browse files Browse the repository at this point in the history
Partially Fixes geerlingguy#510

This will create the expected data directory. This most likely does not
address protections in place because of AppArmor on Ubuntu

Have to account for MariaDB and MySQL's differences in initalizing a new
system
  • Loading branch information
misilot committed Jul 18, 2023
1 parent 8f0eef9 commit bd0d28a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@
- mysql_log_error | default(false)
tags: ['skip_ansible_galaxy']

- name: Initialize mysql when mysql_datadir is customized (MySQL)
ansible.builtin.command: mysqld --initialize-insecure --user=mysql --datadir={{ mysql_datadir }}
args:
creates: "{{ mysql_datadir }}/mysql"
when: mysql_datadir != "/var/lib/mysql" and ('5.7.' in mysql_cli_version.stdout or '8.0.' in mysql_cli_version.stdout)

- name: Initialize mysql when mysql_datadir is customized (MariaDB)
ansible.builtin.command: mysql_install_db
args:
creates: "{{ mysql_datadir }}/mysql"
when: mysql_datadir != "/var/lib/mysql" and ('5.7.' not in mysql_cli_version.stdout or '8.0.' not in mysql_cli_version.stdout)

- name: Ensure MySQL is started and enabled on boot.
ansible.builtin.service:
name: "{{ mysql_daemon }}"
Expand Down

0 comments on commit bd0d28a

Please sign in to comment.