refs #8414 - Add new db section
This commit is contained in:
parent
5a32e5ba42
commit
5da2adfce2
|
@ -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;
|
|
@ -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
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
loop: "{{ certificates }}"
|
loop: "{{ certificates }}"
|
||||||
notify: restart-mariadb
|
notify: restart-mariadb
|
||||||
|
|
||||||
- when: production is true
|
- when: db.branch == 'production'
|
||||||
block:
|
block:
|
||||||
- name: Set MariaDB custom configuration Production
|
- name: Set MariaDB custom configuration Production
|
||||||
copy:
|
copy:
|
||||||
|
@ -104,10 +104,10 @@
|
||||||
- /mnt/local-backup
|
- /mnt/local-backup
|
||||||
Make sure they are correctly configured and accessible.
|
Make sure they are correctly configured and accessible.
|
||||||
|
|
||||||
- when: production is false or production is not defined
|
- when: db.branch == 'test'
|
||||||
|
|
||||||
block:
|
block:
|
||||||
- name: Set MariaDB custom configuration Test-DB-DEV
|
- name: Set MariaDB custom configuration TestDB
|
||||||
copy:
|
copy:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: /etc/mysql/mariadb.conf.d/
|
dest: /etc/mysql/mariadb.conf.d/
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
- "files/mariaconfigfiles/z92-testing_dev.cnf"
|
- "files/mariaconfigfiles/z92-testing_dev.cnf"
|
||||||
notify: restart-mariadb
|
notify: restart-mariadb
|
||||||
|
|
||||||
- name: Set MariaBackup custom template configuration Test-DB-DEV
|
- name: Set MariaBackup custom template configuration TestDB
|
||||||
template:
|
template:
|
||||||
src: test-db_dev/apply.config.sh
|
src: test-db_dev/apply.config.sh
|
||||||
dest: /root/mariabackup/
|
dest: /root/mariabackup/
|
||||||
|
@ -127,7 +127,7 @@
|
||||||
group: root
|
group: root
|
||||||
mode: u=rw,g=,o=
|
mode: u=rw,g=,o=
|
||||||
|
|
||||||
- name: Set MariaDB local configuration file for Test-DB-DEV
|
- name: Set MariaDB local configuration file for TestDB
|
||||||
copy:
|
copy:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: /root/mariabackup/
|
dest: /root/mariabackup/
|
||||||
|
@ -135,10 +135,51 @@
|
||||||
group: root
|
group: root
|
||||||
mode: u=rw,g=r,o=r
|
mode: u=rw,g=r,o=r
|
||||||
with_items:
|
with_items:
|
||||||
- "mariabackuptest_dev/apply.sql"
|
- "mariabackuptest/apply.sql"
|
||||||
- "mariabackuptest_dev/bacula-after.sh"
|
- "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:
|
debug:
|
||||||
msg: |
|
msg: |
|
||||||
Remember to check the following mount points:
|
Remember to check the following mount points:
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
baculaDir=/mnt/mysqldata/bacula-restore
|
baculaDir=/mnt/mysqldata/bacula-restore
|
||||||
|
|
||||||
# Database branch name
|
# Database branch name
|
||||||
dbBranch={{ dbBranch }}
|
dbBranch={{ db.branch }}
|
||||||
|
|
||||||
# Database environment
|
# Database environment
|
||||||
dbEnvironment={{ dbEnvironment }}
|
dbEnvironment={{ dbEnvironment }}
|
||||||
|
@ -16,5 +16,5 @@ dbClusterSiblings=()
|
||||||
jenkinsAuth=jenkins:{{ lookup(passbolt, 'jenkinsAuth', folder_parent_id=passbolt_folder).password }}
|
jenkinsAuth=jenkins:{{ lookup(passbolt, 'jenkinsAuth', folder_parent_id=passbolt_folder).password }}
|
||||||
|
|
||||||
# Jenkins job URL
|
# 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 }}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue