Commit 243ad1b6 by Kevin Falcone

Run migrate on every DB in DATABASES for both lms and the cms

Does so by running the edxapp role just to generate config (as
controlled by check-migrations.sh's use of the --tag) and then
the tasks in the playbook are hardcoded to always run, regardless
of the tag.  Because the edxapp play has run, the tasks have
access to the various config variables containing DATABASES
and can tell what DBs are in use.

Skip the read replica
parent 136e3a36
......@@ -4,14 +4,32 @@
gather_facts: False
vars:
db_dry_run: "--list"
roles:
- edxapp
tasks:
- name: migrate
- name: migrate lms
shell: >
chdir={{ edxapp_code_dir }}
python manage.py {{ item }} migrate --noinput {{ db_dry_run }} --settings=aws_migrate
python manage.py lms migrate --database {{ item }} --noinput {{ db_dry_run }} --settings=aws_migrate
environment:
DB_MIGRATION_USER: "{{ COMMON_MYSQL_MIGRATE_USER }}"
DB_MIGRATION_PASS: "{{ COMMON_MYSQL_MIGRATE_PASS }}"
# Migrate any database in the config, but not the read_replica
when: item != 'read_replica'
with_items:
- lms
- cms
- "{{ lms_auth_config.DATABASES.keys() }}"
tags:
- always
- name: migrate cms
shell: >
chdir={{ edxapp_code_dir }}
python manage.py cms migrate --database {{ item }} --noinput {{ db_dry_run }} --settings=aws_migrate
environment:
DB_MIGRATION_USER: "{{ COMMON_MYSQL_MIGRATE_USER }}"
DB_MIGRATION_PASS: "{{ COMMON_MYSQL_MIGRATE_PASS }}"
# Migrate any database in the config, but not the read_replica
when: item != 'read_replica'
with_items:
- "{{ cms_auth_config.DATABASES.keys() }}"
tags:
- always
......@@ -58,13 +58,12 @@ extra_var_args+=" -e edxapp_code_dir=${WORKSPACE}/edx-platform"
extra_var_args+=" -e edxapp_user=jenkins"
extra_var_args+=" -e EDXAPP_CFG_DIR=${WORKSPACE}"
# Generate the json configuration files
ansible-playbook -c local $extra_var_args --tags edxapp_cfg -i localhost, -s -U jenkins edxapp.yml
# Run migrations and replace literal '\n' with actual newlines to make the output
# easier to read
# We use the edxapp_cfg tag so that the edxapp role will generate config files but
# nothing else. The actual migrate commands are then run from the playbook.
ansible-playbook -v -c local $extra_var_args -i localhost, -s -U jenkins edxapp_migrate.yml | sed 's/\\n/\n/g'
ansible-playbook -v -c local $extra_var_args --tags edxapp_cfg -i localhost, -s -U jenkins edxapp_migrate.yml | sed 's/\\n/\n/g'
#We don't care about the exit status of the `sed`
exit ${PIPESTATUS[0]}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment