Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
configuration
Commits
a75f7cad
Commit
a75f7cad
authored
Jun 27, 2016
by
John Eskew
Committed by
GitHub
Jun 27, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3162 from edx/pipeline/jeskew/build_migrate_deploy
Initial play to run Django migrations.
parents
8e3992b3
4d16ec29
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
playbooks/continuous_delivery/run_migrations.yml
+71
-0
No files found.
playbooks/continuous_delivery/run_migrations.yml
0 → 100644
View file @
a75f7cad
# This playbook will check for migrations that need to be run for Django applications within a larger
# Django application. If migrations exist, it will run the migrations while saving the output as an artifact.
#
# The playbook uses the Django management commands found in this Django app repo:
# https://github.com/edx/edx-django-release-util
# So the Django app above needs to be installed in the Django app being checked for migrations.
#
# Required variables for this playbook:
#
# - APPLICATION_PATH - the top-level path of the Django application; the application lives underneath
# this directory in a directory with the same name as APPLICATION_NAME.
# NOTE: It is assumed that edx-django-release-util is one of its INSTALLED_APPS.
# - APPLICATION_NAME - The name of the application that we are migrating.
# - APPLICATION_USER - user which is meant to run the application
# - ARTIFACT_PATH - the path where the migration artifacts should be copied after completion
# - HIPCHAT_TOKEN - API token to send messages to hipchat
# - 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)
#
# Other variables:
# - unapplied_migrations_output - the filename where the unapplied migration YAML output is stored
# - migration_output - the filename where the migration output is saved
#
# Example command line to run this playbook:
# ansible-playbook -vvvv -i "localhost," -c local \
# -e @overrides.yml \
# run_migrations.yml
#
-
hosts
:
all
vars
:
unapplied_migrations_output
:
unapplied_migrations.yml
migration_output
:
migration_output.yml
HIPCHAT_URL
:
https://api.hipchat.com/v2/
COMMAND_PREFIX
:
"
.
{{
APPLICATION_PATH
}}/{{
APPLICATION_NAME
}}_env;
DB_MIGRATION_USER={{
DB_MIGRATION_USER
}}
DB_MIGRATION_PASS={{
DB_MIGRATION_PASS
}}
/edx/bin/python.{{
APPLICATION_NAME
}}
/edx/bin/manage.{{
APPLICATION_NAME
}}
"
gather_facts
:
False
tasks
:
-
name
:
Create a temporary directory for the migration output.
command
:
mktemp -d
become_user
:
"
{{
APPLICATION_USER
}}"
register
:
temp_output_dir
-
name
:
generate list of unapplied migrations
shell
:
'
{{
COMMAND_PREFIX
}}
show_unapplied_migrations
--output_file
"{{
temp_output_dir.stdout
}}/{{
unapplied_migrations_output
}}"'
become_user
:
"
{{
APPLICATION_USER
}}"
-
name
:
migrate to apply any unapplied migrations
shell
:
'
{{
COMMAND_PREFIX
}}
run_migrations
"{{
temp_output_dir.stdout
}}/{{
unapplied_migrations_output
}}"
--output_file
"{{
temp_output_dir.stdout
}}/{{
migration_output
}}"'
become_user
:
"
{{
APPLICATION_USER
}}"
-
name
:
Transfer artifacts to the proper place.
fetch
:
src
:
"
{{
temp_output_dir.stdout
}}/{{
item
}}"
dest
:
"
{{
ARTIFACT_PATH
}}"
flat
:
True
fail_on_missing
:
True
mode
:
0700
with_items
:
-
"
{{
unapplied_migrations_output
}}"
-
"
{{
migration_output
}}"
-
name
:
Send Hipchat notification cleanup has finished
hipchat_2_0_0_1
:
api
:
"
{{
HIPCHAT_URL
}}"
token
:
"
{{
HIPCHAT_TOKEN
}}"
room
:
"
{{
HIPCHAT_ROOM
}}"
msg
:
"
Migrations
have
completed."
ignore_errors
:
yes
when
:
HIPCHAT_TOKEN is defined
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment