This commit is contained in:
Greg Fodor 2019-02-01 07:36:05 +00:00
Родитель 2239ddee7c
Коммит 1f24ce7a81
7 изменённых файлов: 78 добавлений и 5 удалений

Просмотреть файл

@ -1,9 +1,9 @@
---
- hosts: all
gather_facts: false
gather_facts: true
become: true
become_user: "{{ false if connection == 'local' else 'root' }}"
become_user: "root"
connection: "{{ connection }}"
roles:
- role: migrate

Просмотреть файл

@ -1,6 +1,58 @@
---
- block:
- name: Ensure JRE
apt: name=default-jre
become_user: 'root'
- name: Include environment specific secrets
include_vars:
file: "{{ secrets_path }}/roles/migrate/vars/{{ env }}.yml"
- name: Include environment specific vars
include_vars:
file: "roles/migrate/vars/{{ env }}.yml"
- name: Add Docker GPG key
apt_key: url=https://download.docker.com/linux/ubuntu/gpg
- name: Add Docker APT repository
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ansible_distribution_release}} stable
- name: Install list of packages
apt:
name: ['apt-transport-https','ca-certificates','curl','software-properties-common','docker-ce']
state: present
update_cache: yes
- name: Create work directory
tempfile:
state: directory
suffix: deploy
register: work_dir
- name: Checkout hubs-ops
git:
repo: "{{ ops_repo }}"
dest: "{{ work_dir.path }}"
- name: "Write configs"
template:
src: "flyway.conf.j2"
dest: "{{ work_dir.path }}/db/{{ item }}/conf/flyway.conf"
loop: "{{ schemas }}"
- name: Baseline schemas
shell: "docker run --mount type=bind,source={{ work_dir.path }}/db/{{ item }}/conf,target=/conf --mount type=bind,source={{ work_dir.path }}/db/{{ item }}/sql,target=/sql --network=host --rm boxfuse/flyway -configFiles=/conf/flyway.conf baseline"
args:
chdir: "{{ work_dir.path }}/db/{{ item }}"
loop: "{{ schemas }}"
- name: Migrate schemas
shell: "docker run --mount type=bind,source={{ work_dir.path }}/db/{{ item }}/conf,target=/conf --mount type=bind,source={{ work_dir.path }}/db/{{ item }}/sql,target=/sql --network=host --rm boxfuse/flyway -configFiles=/conf/flyway.conf migrate"
args:
chdir: "{{ work_dir.path }}/db/{{ item }}"
loop: "{{ schemas }}"
always:
- name: Remove work directory
file:
path: "{{ work_dir.path }}"
state: absent

Просмотреть файл

@ -0,0 +1,6 @@
flyway.user={{ db_user }}
flyway.password={{ db_password }}
flyway.schemas={{ item }}
flyway.locations=filesystem:/sql
flyway.table=flyway_hubs_{{ item }}_schema_history
flyway.url={{ db_url }}

Просмотреть файл

@ -0,0 +1,2 @@
---

Просмотреть файл

@ -0,0 +1,4 @@
---
db_url: jdbc:postgresql://localhost:5432/ret_dev
db_password: postgres

Просмотреть файл

@ -1,2 +1,9 @@
---
db_user: postgres
schemas:
- public
- ret_admin
ops_repo: https://github.com/mozilla/hubs-ops.git

Просмотреть файл

@ -0,0 +1,2 @@
---