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 Apr 18, 2023
1 parent e322340 commit 6aeafa9
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 "mariadb-server" not in mysql_packages

- 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 "mariadb-server" in mysql_packages

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

0 comments on commit 6aeafa9

Please sign in to comment.