Skip to content

Commit

Permalink
feat: add mysql init job patch and fix command on mongo init job (edu…
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrrypg authored Jan 17, 2024
1 parent 4ef0da5 commit d838e22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drydock/templates/drydock/k8s/drydock-jobs/mongodb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ spec:
args:
- |
echo "Initialising MongoDB..."
mongo --host {{MONGODB_HOST }} -u "{{ MONGODB_ROOT_USERNAME }}" -p "{{ MONGODB_ROOT_PASSWORD }}" admin <<EOF
mongo --host {{MONGODB_HOST }} {% if MONGODB_ROOT_USERNAME and MONGODB_ROOT_PASSWORD %} -u {{ MONGODB_ROOT_USERNAME }} -p {{ MONGODB_ROOT_PASSWORD }} {% endif %} admin <<EOF
{%- endif %}
{%- if MONGODB_USERNAME %}
if (db.getUser("{{ MONGODB_USERNAME }}") == null) {
db.createUser({
user: "{{ MONGODB_USERNAME }}",
pwd: "{{ MONGODB_PASSWORD }}",
pwd: "{{ MONGODB_PASSWORD }}",
roles: [
{ role: "readWrite", db: "{{ MONGODB_DATABASE }}" },
{% if FORUM_DOCKER_IMAGE is defined %}{ role: "readWrite", db: "{{ FORUM_MONGODB_DATABASE }}" },{% endif %}
Expand All @@ -44,6 +45,6 @@ spec:
})
}
{%- endif %}
{{ patch("drydock-mongodb-init-job") }}
{{ patch("drydock-mongodb-init-job")|indent(12) }}
exit
EOF
1 change: 1 addition & 0 deletions drydock/templates/drydock/k8s/drydock-jobs/mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ spec:
mysql -u {{ MYSQL_ROOT_USERNAME }} --password="{{ MYSQL_ROOT_PASSWORD }}" --host "{{ MYSQL_HOST }}" --port {{ MYSQL_PORT }} -e "CREATE USER IF NOT EXISTS '{{ OPENEDX_MYSQL_USERNAME }}';"
mysql -u {{ MYSQL_ROOT_USERNAME }} --password="{{ MYSQL_ROOT_PASSWORD }}" --host "{{ MYSQL_HOST }}" --port {{ MYSQL_PORT }} -e "ALTER USER '{{ OPENEDX_MYSQL_USERNAME }}'@'%' IDENTIFIED BY '{{ OPENEDX_MYSQL_PASSWORD }}';"
mysql -u {{ MYSQL_ROOT_USERNAME }} --password="{{ MYSQL_ROOT_PASSWORD }}" --host "{{ MYSQL_HOST }}" --port {{ MYSQL_PORT }} -e "GRANT ALL ON {{ OPENEDX_MYSQL_DATABASE }}.* TO '{{ OPENEDX_MYSQL_USERNAME }}'@'%';"
{{ patch("drydock-mysql-init-job")|indent(10) }}

0 comments on commit d838e22

Please sign in to comment.