-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add small MariaDB docker role, for running on a single node #459
Merged
+293
−34
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,5 @@ invite_manage_provision_oauth_rs_scopes: "openid" | |
invite_mock_install: false | ||
# Override is in the dockerX.env host_var files | ||
invite_cronjobmaster: true | ||
invite_docker_networks: | ||
- name: loadbalancer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hier gaat het wel goed ;) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
docker_mariadb_network_range: "172.21.21.0/24" | ||
mysql_backup_user: backup_user | ||
backup_node: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[mariadb] | ||
sql_mode=NO_ENGINE_SUBSTITUTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
--- | ||
- name: Create MariaDB volume | ||
community.docker.docker_volume: | ||
name: openconext_mariadb | ||
state: present | ||
- name: Create MariaDB config dir | ||
ansible.builtin.file: | ||
path: /opt/openconext/mariadb/ | ||
owner: root | ||
group: root | ||
mode: "0755" | ||
state: directory | ||
|
||
- name: Copy mariadb config file | ||
ansible.builtin.copy: | ||
src: settings.cnf | ||
dest: /opt/openconext/mariadb/settings.cnf | ||
owner: root | ||
group: root | ||
mode: "0644" | ||
|
||
- name: Create MariaDB network | ||
community.docker.docker_network: | ||
name: openconext_mariadb | ||
state: present | ||
internal: false | ||
ipam_config: | ||
- subnet: "{{ docker_mariadb_network_range }}" | ||
|
||
- name: Create the MariaDB container | ||
community.docker.docker_container: | ||
name: openconext_mariadb | ||
image: mariadb:10.6 | ||
state: started | ||
pull: true | ||
restart_policy: "always" | ||
ports: "127.0.0.1:3306:3306" | ||
networks: | ||
- name: "openconext_mariadb" | ||
mounts: | ||
- type: volume | ||
source: openconext_mariadb | ||
target: /var/lib/mysql | ||
- type: bind | ||
source: /opt/openconext/mariadb/settings.cnf | ||
target: /etc/mysql/conf.d/settings.cnf | ||
env: | ||
MARIADB_ROOT_PASSWORD: "{{ mariadb_root_password }}" | ||
|
||
- name: Create database | ||
community.mysql.mysql_db: | ||
name: "{{ item }}" | ||
state: present | ||
login_user: root | ||
login_host: localhost | ||
login_password: "{{ mariadb_root_password }}" | ||
with_items: | ||
- "{{ databases.names }}" | ||
|
||
- name: Create database user | ||
community.mysql.mysql_user: | ||
name: "{{ item[0].name }}" | ||
host: "{{ item[1] }}" | ||
password: "{{ item[0].password }}" | ||
priv: "{{ item[0].db_name }}.*:{{ item[0].privilege }}" | ||
state: present | ||
append_privs: true | ||
login_user: root | ||
login_host: localhost | ||
login_password: "{{ mariadb_root_password }}" | ||
# no_log: true | ||
with_nested: | ||
- "{{ databases.users }}" | ||
- "{{ database_clients }}" | ||
|
||
- name: Add mariadb backup user | ||
community.mysql.mysql_user: | ||
name: "{{ mysql_backup_user }}" | ||
password: "{{ mysql_backup_password }}" | ||
login_user: root | ||
login_password: "{{ mariadb_root_password }}" | ||
login_host: localhost | ||
priv: "*.*:SELECT,RELOAD,PROCESS,LOCK TABLES,BINLOG MONITOR,CONNECTION ADMIN,SHOW VIEW" | ||
state: present | ||
# no_log: true | ||
|
||
- name: Create the backup directory | ||
ansible.builtin.file: | ||
path: /home/backup | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: "0700" | ||
when: | ||
- backup_node | bool | ||
|
||
- name: Put mariadb_backup script | ||
ansible.builtin.template: | ||
src: "mariadb_backup.sh.j2" | ||
dest: "/usr/local/sbin/mariadb_backup.sh" | ||
mode: "0700" | ||
owner: root | ||
when: | ||
- backup_node | bool | ||
|
||
- name: Create cron symlink for backup script | ||
file: | ||
src: /usr/local/sbin/mariadb_backup.sh | ||
dest: /etc/cron.daily/db_backup | ||
state: link | ||
mode: 0700 | ||
owner: root | ||
when: | ||
- backup_node | bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
umask 0077 | ||
|
||
declare -x PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin | ||
|
||
MYSQL_USER="{{ mysql_backup_user }}" | ||
MYSQL_PASS="{{ mysql_backup_password }}" | ||
FOLDER="/home/backup" | ||
|
||
DAY=$(/bin/date +'%a') | ||
|
||
echo "-- Remove old backups --" | ||
find /home/backup/ -type f -ctime +2 -delete | ||
|
||
echo "-- START new backups --" | ||
|
||
echo "SET autocommit=0;SET unique_checks=0;SET foreign_key_checks=0;" > tmp_sqlhead.sql | ||
echo "SET autocommit=1;SET unique_checks=1;SET foreign_key_checks=1;" > tmp_sqlend.sql | ||
|
||
if [ -z "$1" ] | ||
then | ||
echo "-- Dumping all DB ..." | ||
for I in $(docker exec openconext_mariadb mariadb -u $MYSQL_USER --password=$MYSQL_PASS -e 'show databases' -s --skip-column-names); | ||
do | ||
if [ "$I" = information_schema ] || [ "$I" = mysql ] || [ "$I" = sys ] || [ "$I" = performance_schema ] # exclude this DB | ||
then | ||
echo "-- Skip $I ..." | ||
continue | ||
fi | ||
echo "-- Dumping $I ..." | ||
# Pipe compress and concat the head/end with the stoutput of mysqlump ( '-' cat argument) | ||
docker exec openconext_mariadb mysqldump -u $MYSQL_USER --password=$MYSQL_PASS $I | cat tmp_sqlhead.sql - tmp_sqlend.sql | gzip -fc > "$FOLDER/$DAY-$I.sql.gz" | ||
done | ||
|
||
else | ||
I=$1; | ||
echo "-- Dumping $I ..." | ||
# Pipe compress and concat the head/end with the stoutput of mysqlump ( '-' cat argument) | ||
docker exec openconext_mariadb mysqldump -u $MYSQL_USER --password=$MYSQL_PASS $I | cat tmp_sqlhead.sql - tmp_sqlend.sql | gzip -fc > "$FOLDER/$DAY-$I.sql.gz" | ||
fi | ||
|
||
# remove tmp files | ||
rm tmp_sqlhead.sql | ||
rm tmp_sqlend.sql | ||
|
||
echo "-- FINISH —" | ||
|
||
umask 0022 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,5 @@ pdp_manage_provision_samlsp_trusted_proxy: false | |
pdp_manage_provision_samlsp_sign: false | ||
pdp_spring_flyway_enabled: true | ||
pdp_manage_push_testmode: true | ||
pdp_docker_networks: | ||
-name: loadbalancer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mis een spatie |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je vervangt hierdoor de list door een hash. Moet de default niet zijn:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Klopt. Het aardige is dat het wel gewoon werkt, alles op TEST is met deze branch gedeployed :)