openreplay/scripts/helm/migration.yaml
Rajesh Rajendran 5ad8200f86
Feature: Upgrade script (#73)
* feat(upgrade): upgrading dbs

* feat(installation): migration script

* fix(upgrdae): proper db version

Signed-off-by: Rajesh Rajendran <rjshrjndrn@gmail.com>

* chore(upgrade): update install.sh

Signed-off-by: Rajesh Rajendran <rjshrjndrn@gmail.com>
2021-07-04 10:52:27 +00:00

46 lines
1.7 KiB
YAML

---
- hosts: localhost
environment:
KUBECONFIG: "{{ kubeconfig_path }}"
tasks:
- debug:
var: migration_versions
- block:
- name: generating migration db paths
set_fact:
db_path: "{{dst_list | default([])}} + [ '{{ item[0] }}/*.sql' ]"
with_items: "{{ migration_versions.split(',') }}"
- name: Migrate postgresql
shell: |
file="{{ item|basename }}"
kubectl exec -n db postgresql-postgresql-0 -- /bin/bash -c "rm -rf /tmp/$file"
kubectl cp -n db $file postgresql-postgresql-0:/tmp/
kubectl exec -n db postgresql-postgresql-0 -- /bin/bash -c "PGPASSWORD=asayerPostgres psql -U postgres -f /tmp/$file" &> "{{ playbook_dir }}"/postgresql_init.log
args:
chdir: db/init_dbs/postgresql
with_fileglob:
- "{{ db_path }}"
tags:
- postgresql
- block:
- name: generating migration db paths
set_fact:
db_path: "{{dst_list | default([])}} + [ '{{ item[0] }}/*.sql' ]"
with_items: "{{ migration_versions.split(',') }}"
- name: Restoring clickhouse data
shell: |
file="{{ item|basename }}"
kubectl exec -n db clickhouse-0 -- /bin/bash -c "rm -rf /tmp/$file"
kubectl cp -n db $file clickhouse-0:/tmp/
kubectl exec -n db clickhouse-0 -- /bin/bash -c "clickhouse-client < /tmp/$file" 2>&1 | tee -a "{{ playbook_dir }}"/clickhouse_init.log
args:
chdir: db/init_dbs/clickhouse/create
with_fileglob:
- "{{ db_path }}"
retries: 3
delay: 60
register: result
until: result.rc == 0
tags:
- clickhouse
when: enterprise_edition_license|length > 0