Commit d14ca0a7 by John Eskew

Use temporary file for storage of migration output.

Transfer output artifacts after completion to preserve them.
parent 093da1e6
...@@ -8,8 +8,10 @@ ...@@ -8,8 +8,10 @@
# Required variables for this playbook: # Required variables for this playbook:
# #
# - application_path - the path where the Django application with potential migrations is installed # - application_path - the path where the Django application with potential migrations is installed
# - unapplied_migrations_path - the path where the unapplied migration YAML output is stored # NOTE: It is assumed that edx-django-release-util is one of its INSTALLED_APPS.
# - migration_output_path - the path where the migration output is saved # - unapplied_migrations_output - the filename where the unapplied migration YAML output is stored
# - migration_output - the filename where the migration output is saved
# - artifact_path - the path where the migration artifacts should be copied after completion
# - hipchat_token - API token to send messages to hipchat # - hipchat_token - API token to send messages to hipchat
# - hipchat_room - ID or name of the room to send the notification # - hipchat_room - ID or name of the room to send the notification
# - hipchat_url - URL of the hipchat API (defaults to v1 of the api) # - hipchat_url - URL of the hipchat API (defaults to v1 of the api)
...@@ -23,24 +25,34 @@ ...@@ -23,24 +25,34 @@
- hosts: all - hosts: all
vars: vars:
application_path: /usr/src/myapp application_path: /usr/src/my_django_app
unapplied_migrations_path: /tmp/unapplied_migrations.yml unapplied_migrations_output: unapplied_migrations.yml
migration_output_path: /tmp/migration_output.yml migration_output: migration_output.yml
hipchat_url: https://api.hipchat.com/v2/ hipchat_url: https://api.hipchat.com/v2/
gather_facts: False gather_facts: False
connection: local connection: local
tasks: tasks:
- name: Create a temporary directory for the migration output.
command: mktemp -d
register: temp_output_dir
- name: generate list of unapplied migrations - name: generate list of unapplied migrations
command: python manage.py show_unapplied_migrations --output_file "{{ unapplied_migrations_path }}" command: python manage.py show_unapplied_migrations --output_file "{{ temp_output_dir.stdout }}/{{ unapplied_migrations_output }}"
args: args:
chdir: "{{ application_path }}" chdir: "{{ application_path }}"
- name: migrate to apply any unapplied migrations - name: migrate to apply any unapplied migrations
command: python manage.py run_migrations "{{ unapplied_migrations_path }}" --output_file "{{ migration_output_path }}" command: python manage.py run_migrations "{{ temp_output_dir.stdout }}/{{ unapplied_migrations_output }}" --output_file "{{ temp_output_dir.stdout }}/{{ migration_output }}"
args: args:
chdir: "{{ application_path }}" chdir: "{{ application_path }}"
- name: Transfer artifacts to the proper place.
copy:
src: "{{ temp_output_dir.stdout }}/"
dest: "{{ artifact_path }}"
mode: 0700
- name: Send Hipchat notification cleanup has finished - name: Send Hipchat notification cleanup has finished
hipchat_2_0_0_1: hipchat_2_0_0_1:
api: "{{ hipchat_url }}" api: "{{ hipchat_url }}"
......
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