Merge pull request 'refs #8414 - Add new db section' (!60) from 8414_Refactor_mariadb_variables_begin_with_db into main

Reviewed-on: #60
Reviewed-by: Juan Ferrer <juan@verdnatura.es>
This commit is contained in:
Xavi Lleó 2025-02-03 09:36:10 +00:00
commit 0b26de0190
6 changed files with 125 additions and 10 deletions

View File

@ -0,0 +1,23 @@
UPDATE vn2008.tblContadores
SET dbproduccion = FALSE;
DELETE FROM util.binlogQueue;
GRANT
SELECT,
INSERT,
UPDATE,
DELETE,
CREATE,
DROP,
INDEX,
ALTER,
CREATE TEMPORARY TABLES,
CREATE VIEW,
EVENT,
TRIGGER,
SHOW VIEW,
CREATE ROUTINE,
ALTER ROUTINE,
EXECUTE
ON *.* TO developerBoss;

View File

@ -0,0 +1,51 @@
#!/bin/bash
set -e
myDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$myDir/config.sh"
. "$myDir/apply.config.sh"
todayDir=$(date +%Y-%m-%d)
pattern="$baculaDir/mnt/local-backup/${todayDir}_??-??_full.gz"
files=($pattern)
backupFile="${files[0]}"
"$myDir/restore-backup.sh" "$backupFile"
rm -r "$baculaDir"
if [[ "${#dbClusterSiblings[@]}" -gt "0" ]]; then
for node in "${dbClusterSiblings[@]}"; do
ssh root@$node service mysql stop
ssh root@$node "if pgrep mariadbd; then pkill -9 mariadbd; fi"
done
galera_new_cluster
else
service mariadb start
fi
echo "Applying custom script."
mysql -e "UPDATE util.config SET environment = '$dbEnvironment', lastDump = NOW()"
mysql < "$myDir/apply.sql"
echo "Upgrading tables."
mysql_upgrade
echo "Applying repository changes."
curl --silent --request POST --location --user "$jenkinsAuth" "$jenkinsUrl/build?delay=0sec"
echo "Waiting for Jenkins job to end."
jobResult=null
while [ "$jobResult" = "null" ]; do
sleep 10
jobResult=$(curl --silent --location --user "$jenkinsAuth" "$jenkinsUrl/lastBuild/api/json" | jq --raw-output ".result")
done
echo "Job result: $jobResult"
echo "Promoting to master."
"/root/scripts/promote-master.sh"
for node in "${dbClusterSiblings[@]}"; do
ssh root@$node service mysql start
done

View File

@ -81,7 +81,7 @@
loop: "{{ certificates }}"
notify: restart-mariadb
- when: production is true
- when: db.branch == 'production'
block:
- name: Set MariaDB custom configuration Production
copy:
@ -104,10 +104,10 @@
- /mnt/local-backup
Make sure they are correctly configured and accessible.
- when: production is false or production is not defined
- when: db.branch == 'test'
block:
- name: Set MariaDB custom configuration Test-DB-DEV
- name: Set MariaDB custom configuration TestDB
copy:
src: "{{ item }}"
dest: /etc/mysql/mariadb.conf.d/
@ -119,7 +119,7 @@
- "files/mariaconfigfiles/z92-testing_dev.cnf"
notify: restart-mariadb
- name: Set MariaBackup custom template configuration Test-DB-DEV
- name: Set MariaBackup custom template configuration TestDB
template:
src: test-db_dev/apply.config.sh
dest: /root/mariabackup/
@ -127,7 +127,7 @@
group: root
mode: u=rw,g=,o=
- name: Set MariaDB local configuration file for Test-DB-DEV
- name: Set MariaDB local configuration file for TestDB
copy:
src: "{{ item }}"
dest: /root/mariabackup/
@ -135,10 +135,51 @@
group: root
mode: u=rw,g=r,o=r
with_items:
- "mariabackuptest_dev/apply.sql"
- "mariabackuptest_dev/bacula-after.sh"
- "mariabackuptest/apply.sql"
- "mariabackuptest/bacula-after.sh"
- name: Reminder to check mount points environment Test-DB-DEV
- name: Reminder to check mount points environment TestDB
debug:
msg: |
Remember to check the following mount points:
- /mnt/mysqltmp
Make sure they are correctly configured and accessible.
- when: db.branch == 'dev'
block:
- name: Set MariaDB custom configuration DevDB
copy:
src: "{{ item }}"
dest: /etc/mysql/mariadb.conf.d/
owner: root
group: root
mode: u=rw,g=r,o=r
with_items:
- "files/mariaconfigfiles/z90-vn.cnf"
- "files/mariaconfigfiles/z92-testing_dev.cnf"
notify: restart-mariadb
- name: Set MariaBackup custom template configuration DevDB
template:
src: test-db_dev/apply.config.sh
dest: /root/mariabackup/
owner: root
group: root
mode: u=rw,g=,o=
- name: Set MariaDB local configuration file for DevDB
copy:
src: "{{ item }}"
dest: /root/mariabackup/
owner: root
group: root
mode: u=rw,g=r,o=r
with_items:
- "mariabackupdev/apply.sql"
- "mariabackupdev/bacula-after.sh"
- name: Reminder to check mount points environment DevDB
debug:
msg: |
Remember to check the following mount points:

View File

@ -4,7 +4,7 @@
baculaDir=/mnt/mysqldata/bacula-restore
# Database branch name
dbBranch={{ dbBranch }}
dbBranch={{ db.branch }}
# Database environment
dbEnvironment={{ dbEnvironment }}
@ -16,5 +16,5 @@ dbClusterSiblings=()
jenkinsAuth=jenkins:{{ lookup(passbolt, 'jenkinsAuth', folder_parent_id=passbolt_folder).password }}
# Jenkins job URL
jenkinsUrl=https://jenkins.verdnatura.es/job/Scheduler/job/db-apply-changes-{{ dbBranch }}
jenkinsUrl=https://jenkins.verdnatura.es/job/Scheduler/job/db-apply-changes-{{ db.branch }}