Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize Custom Data Directory #518

Closed
wants to merge 2 commits into from

Conversation

misilot
Copy link
Contributor

@misilot misilot commented Feb 23, 2023

Partially Fixes #510

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

@geerlingguy
Copy link
Owner

Since I don't customize the dir, I'd like someone else to confirm this works / test it out (preferably across a couple platforms) before merging. Also, it might be nice to test it in CI.

@misilot
Copy link
Contributor Author

misilot commented Feb 27, 2023 via email

@widhalmt
Copy link

widhalmt commented Apr 6, 2023

Hi. I just ran into the same issue. I do have to change the data dir. So I'll check the change. And I can help with the CI part, too.

@widhalmt
Copy link

widhalmt commented Apr 6, 2023

Was easier than expected since there's only one molecule scenario. @geerlingguy I'll post a PR shortly with setting the variable in this one scenario. Is that what you thought of? Or would you like to have an extra scenario to test changed variables? I saw your default scenario is quite straight forward so maybe you want to keep it that way and have another one for more peculiar setups?

@widhalmt
Copy link

widhalmt commented Apr 6, 2023

@misilot I tried your solution on Ubuntu 20.04 with MariaDB 10.3.38. It created the usual InnodDB file but not the default database like the mysql one. It only worked when I ran mysqld_install_db. Maybe you need to change your Merge Request. If it worked for you, I need to dig deeper.

@misilot
Copy link
Contributor Author

misilot commented Apr 18, 2023

@widhalmt let me take a look and try again.

@misilot
Copy link
Contributor Author

misilot commented Apr 18, 2023

@widhalmt so MariaDB and MySQL have different ways to initialize the data directory. I added a conditional to check if mariadb-server exists in the mysql_packages variable.

@@ -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 }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could interfere with later initialization, though, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which later initialization? I can't get molecule to run the rockylinux on my m1 mac, but the ubuntu2204 and 2004, both seem to pass the tests, when specifying an alternate data directory for both mysql and mariadb.

I am trying to modify the github actions to run the additional tests (I believe that is the way to do it?) I can't find a way to have different playbooks in molecule that tear down everything between playbooks.

Copy link

@widhalmt widhalmt Apr 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still depends. @geerlingguy do you want to have an extra molecule scenario for a moved directory or should it be part of default? I made a PR to the PR of @misilot and I'm ready to change as you want it to have.

I can help you @misilot . But in short: If you want two different playbooks, you make two scenarios in Molecule. Copy the default folder and change converge.yml like you want the other playbook to be

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I am working on the logic to check the version number instead of looking for package names, since debian uses mysql in the package name, but is really mariadb, the logic I have doesn't work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I fixed the logic, and they all seem to run locally with molecule. I also added in @widhalmt change to this PR.

@geerlingguy
Copy link
Owner

This is currently failing, but might just need a rebase?

misilot and others added 2 commits July 17, 2023 21:47
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
@misilot
Copy link
Contributor Author

misilot commented Jul 18, 2023

I just rebased, so we will see what it does.

Copy link

This pr has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

@github-actions github-actions bot added the stale label Nov 18, 2023
Copy link

This pr has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

@github-actions github-actions bot closed this Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MySQL fails to start when mysql_datadir is set to anything other than MySQL's default
3 participants