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

[feature] Use MariaDB instead of MySQL #564

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
that must also work on AWX / Ansible Tower / the mgmt pod (where Keybase is not
available, for security reasons). For instance, the following piece of Jinja

lookup("env_secrets", "mysql_super_credentials", "MYSQL_SUPER_PASSWORD")
lookup("env_secrets", "mariadb_super_credentials", "MARIADB_SUPER_PASSWORD")

is the same as `lookup("env", "MYSQL_SUPER_PASSWORD")` on AWX, and the same as
`env_secret_mysql_super_credentials.MYSQL_SUPER_PASSWORD` on the operator's
is the same as `lookup("env", "MARIADB_SUPER_PASSWORD")` on AWX, and the same as
`env_secret_mysql_super_credentials.MARIADB_SUPER_PASSWORD` on the operator's
workstation.

Usage:
Expand Down
2 changes: 1 addition & 1 deletion docker/mgmt/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ iwait() {
save_env_for_ssh_users() {
env -0 | while IFS== read -d '' var val; do
case "$var" in
WP_*|MYSQL_*|HTTPD_*|MGMT_*|KUBERNETES_*|JENKINS_*|POLYLEX_*|VARNISH_*|AWX_*|AWS_*|RESTIC_*)
WP_*|MARIADB_*|MYSQL_*|HTTPD_*|MGMT_*|KUBERNETES_*|JENKINS_*|POLYLEX_*|VARNISH_*|AWX_*|AWS_*|RESTIC_*)
printf "export %s=\"%q\"\n" "$var" "$val" ;;
*) : ;;
esac
Expand Down
14 changes: 7 additions & 7 deletions docker/mgmt/new-wp-site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ main() {

( set -x; wp --path=. core symlink --path_to_version="/wp/$WORDPRESS_VERSION" )

db_host="${MYSQL_DB_HOST:-db}"
db_host="${MARIADB_DB_HOST:-db}"
if [ -f wp-config.php ]; then
# Retrieve DB credentials from wp-config.php
eval "$(perl -ne 'm/(DB_(NAME|USER|PASSWORD)).*, '\''(.*)'\''/ && print lc($1) . "=$3\n";' < wp-config.php)"
Expand All @@ -44,7 +44,7 @@ main() {
CREATE USER '$db_user'@'%' IDENTIFIED BY '$db_password';
SQL_CREATE_USER

( set -x; wp db create --dbuser="$MYSQL_SUPER_USER" --dbpass="$MYSQL_SUPER_PASSWORD" ) || true
( set -x; wp db create --dbuser="$MARIADB_SUPER_USER" --dbpass="$MARIADB_SUPER_PASSWORD" ) || true

do_mysql <<GRANT_PRIVILEGES
GRANT ALL PRIVILEGES ON $db_name.* TO '$db_user'@'%';
Expand Down Expand Up @@ -73,9 +73,9 @@ die () {
}

check_env() {
if [ -z "$MYSQL_SUPER_USER" ] || [ -z "$MYSQL_SUPER_PASSWORD" ]; then
if [ -z "$MARIADB_SUPER_USER" ] || [ -z "$MARIADB_SUPER_PASSWORD" ]; then
die <<MISSING_ENV
Fatal: either MYSQL_SUPER_USER or MYSQL_SUPER_PASSWORD are unset.
Fatal: either MARIADB_SUPER_USER or MARIADB_SUPER_PASSWORD are unset.

Please source the appropriate .env file and try again.

Expand Down Expand Up @@ -106,14 +106,14 @@ MESSAGE
}

check_env_prereqs() {
[ -n "$MYSQL_SUPER_USER" ] || whine_env "MYSQL_SUPER_USER"
[ -n "$MYSQL_SUPER_PASSWORD" ] || whine_env "MYSQL_SUPER_PASSWORD"
[ -n "$MARIADB_SUPER_USER" ] || whine_env "MARIADB_SUPER_USER"
[ -n "$MARIADB_SUPER_PASSWORD" ] || whine_env "MARIADB_SUPER_PASSWORD"
[ -n "$WP_ADMIN_USER" ] || whine_env "WP_ADMIN_USER"
[ -n "$WP_ADMIN_EMAIL" ] || whine_env "WP_ADMIN_EMAIL"
}

do_mysql() {
tee /dev/stderr | (set -x; mysql -h "${db_host}" -u "$MYSQL_SUPER_USER" -p"$MYSQL_SUPER_PASSWORD")
tee /dev/stderr | (set -x; mysql -h "${db_host}" -u "$MARIADB_SUPER_USER" -p"$MARIADB_SUPER_PASSWORD")
}

do_wp_core_install () {
Expand Down