Merge lp:~michael.nelson/open-goal-tracker/ensemble_deploy into lp:open-goal-tracker

Proposed by Michael Nelson
Status: Work in progress
Proposed branch: lp:~michael.nelson/open-goal-tracker/ensemble_deploy
Merge into: lp:open-goal-tracker
Diff against target: 245 lines (+142/-6)
11 files modified
.bzrignore (+1/-0)
fabfile.py (+7/-4)
ogt_project/apache/django.wsgi (+27/-0)
ogt_project/ensemble_deploy/ogt/hooks/db-relation-changed (+35/-0)
ogt_project/ensemble_deploy/ogt/hooks/install (+36/-0)
ogt_project/ensemble_deploy/ogt/hooks/local_settings-template.py (+14/-0)
ogt_project/ensemble_deploy/ogt/hooks/start (+2/-0)
ogt_project/ensemble_deploy/ogt/hooks/stop (+3/-0)
ogt_project/ensemble_deploy/ogt/metadata.yaml (+10/-0)
ogt_project/settings.py (+5/-0)
ogt_project/templates/base.html (+2/-2)
To merge this branch: bzr merge lp:~michael.nelson/open-goal-tracker/ensemble_deploy
Reviewer Review Type Date Requested Status
Michael Nelson Pending
Review via email: mp+69078@code.launchpad.net

Description of the change

Just a WIP. Currently it seems that we're getting both python 2.6 and 2.7 installed which is causing an issue during the install hook: http://paste.ubuntu.com/651735/. After chatting with niemeyer, solved by unsetting PYTHONPATH in the install hook, and created bug 816264.

To post a comment you must log in.
81. By Michael Nelson

Left over file that wasn't added to repo earlier.

82. By Michael Nelson

Put the stop hook in the hooks directory.

83. By Michael Nelson

Add python-virtualenv to install.

84. By Michael Nelson

Updated recipe to reset pythonpath after chatting with niemeyer.

85. By Michael Nelson

Small changes after testing the db relationship.

86. By Michael Nelson

Ensure virtualenvs_path can be set in environ.

87. By Michael Nelson

Updated to use django-socialauth (after finding django_openid_auth is incompatible with mysql :/ ).

88. By Michael Nelson

Included the extra app openid_consumer for django_socialauth.

89. By Michael Nelson

Switch back to django_openid_auth.

90. By Michael Nelson

Initial postgres integration.

91. By Michael Nelson

Small tweaks for postgres deploy.

92. By Michael Nelson

Ensure install is idempotent.

93. By Michael Nelson

Fixed db-relation-changed and added template dir to settings template.

94. By Michael Nelson

Added alias for static media (until updated to separate static service).

Unmerged revisions

94. By Michael Nelson

Added alias for static media (until updated to separate static service).

93. By Michael Nelson

Fixed db-relation-changed and added template dir to settings template.

92. By Michael Nelson

Ensure install is idempotent.

91. By Michael Nelson

Small tweaks for postgres deploy.

90. By Michael Nelson

Initial postgres integration.

89. By Michael Nelson

Switch back to django_openid_auth.

88. By Michael Nelson

Included the extra app openid_consumer for django_socialauth.

87. By Michael Nelson

Updated to use django-socialauth (after finding django_openid_auth is incompatible with mysql :/ ).

86. By Michael Nelson

Ensure virtualenvs_path can be set in environ.

85. By Michael Nelson

Small changes after testing the db relationship.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2011-06-14 17:52:29 +0000
+++ .bzrignore 2011-09-12 20:54:36 +0000
@@ -10,3 +10,4 @@
10.virtualenvs10.virtualenvs
11.downloads11.downloads
12virtualenv12virtualenv
13ogt_project/local_settings.py
1314
=== modified file 'fabfile.py'
--- fabfile.py 2011-06-23 06:30:45 +0000
+++ fabfile.py 2011-09-12 20:54:36 +0000
@@ -2,6 +2,7 @@
2import shutil2import shutil
3import tempfile3import tempfile
4from fabric.api import (4from fabric.api import (
5 env,
5 local,6 local,
6 settings,7 settings,
7 )8 )
@@ -11,14 +12,16 @@
11from zipfile import ZipFile12from zipfile import ZipFile
1213
1314
14def ensure_virtualenv(virtualenvs_path='.virtualenvs',15env.virtualenvs_path = os.environ.get('VIRTUALENVS_PATH', '.virtualenvs')
15 virtualenv_symlink='virtualenv'):16
17
18def ensure_virtualenv(virtualenv_symlink='virtualenv'):
16 # Check the SHA1 hash of the requirements.txt and see if the19 # Check the SHA1 hash of the requirements.txt and see if the
17 # corresponding virtual env already exists, if not create it.20 # corresponding virtual env already exists, if not create it.
18 with open('requirements.txt', 'r') as requirements:21 with open('requirements.txt', 'r') as requirements:
19 digest = sha1(requirements.read()).hexdigest()22 digest = sha1(requirements.read()).hexdigest()
2023
21 real_virtualenvs_path = os.path.realpath(virtualenvs_path)24 real_virtualenvs_path = os.path.realpath(env.virtualenvs_path)
22 venv_matching_requirements = os.path.join(real_virtualenvs_path, 'goaltracker_' + digest)25 venv_matching_requirements = os.path.join(real_virtualenvs_path, 'goaltracker_' + digest)
23 if not os.path.exists(venv_matching_requirements):26 if not os.path.exists(venv_matching_requirements):
24 print("No virtualenv matching requirements.txt found. Creating one now.")27 print("No virtualenv matching requirements.txt found. Creating one now.")
@@ -134,7 +137,7 @@
134137
135def install_jquery_media():138def install_jquery_media():
136 jquery_zip = download_resource(139 jquery_zip = download_resource(
137 'http://jqueryui.com/download/jquery-ui-1.8.10.custom.zip')140 'http://jqueryui.com/download/jquery-ui-1.8.16.custom.zip')
138 # Copy the js and css.141 # Copy the js and css.
139 copy_files_map = {142 copy_files_map = {
140 'js': os.path.join('media-root-dev', 'js', 'jquery'),143 'js': os.path.join('media-root-dev', 'js', 'jquery'),
141144
=== added directory 'ogt_project/apache'
=== added file 'ogt_project/apache/django.wsgi'
--- ogt_project/apache/django.wsgi 1970-01-01 00:00:00 +0000
+++ ogt_project/apache/django.wsgi 2011-09-12 20:54:36 +0000
@@ -0,0 +1,27 @@
1# XXX Move to be a template of the ensemble_deploy/ogt/hooks rather than here.
2import os
3import site
4import sys
5
6# As per http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
7# Remember original sys.path.
8prev_sys_path = list(sys.path)
9
10site.addsitedir('/opt/open-goal-tracker/current/virtualenv/lib/python2.7/site-packages')
11
12# Reorder sys.path so new directories at the front.
13new_sys_path = []
14for item in list(sys.path):
15 if item not in prev_sys_path:
16 new_sys_path.append(item)
17 sys.path.remove(item)
18sys.path[:0] = new_sys_path
19
20project_path = '/opt/open-goal-tracker/current'
21if project_path not in sys.path:
22 sys.path.append(project_path)
23
24os.environ['DJANGO_SETTINGS_MODULE'] = 'ogt_project.settings'
25
26import django.core.handlers.wsgi
27application = django.core.handlers.wsgi.WSGIHandler()
028
=== added directory 'ogt_project/ensemble_deploy'
=== added directory 'ogt_project/ensemble_deploy/ogt'
=== added directory 'ogt_project/ensemble_deploy/ogt/hooks'
=== added file 'ogt_project/ensemble_deploy/ogt/hooks/db-relation-changed'
--- ogt_project/ensemble_deploy/ogt/hooks/db-relation-changed 1970-01-01 00:00:00 +0000
+++ ogt_project/ensemble_deploy/ogt/hooks/db-relation-changed 2011-09-12 20:54:36 +0000
@@ -0,0 +1,35 @@
1#!/bin/bash
2set -eux # -x for verbose logging to ensemble debug-log
3IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{print $1}'|head -n 1`
4ensemble-log "setting ip to $IP"
5relation-set ip=$IP
6
7hooksdir=$PWD
8user=`relation-get user`
9# All values are set together, so checking on a single value is enough
10# If $user is not set, DB is still setting itself up, we exit awaiting next run
11[ -z "$user" ] && exit 0
12password=`relation-get password`
13host=`relation-get host`
14database=`relation-get database`
15
16ensemble-log "Updating local_settings.py."
17cd /opt/open-goal-tracker/current/ogt_project
18sed -e "s/DATABASE_USER/$user/" \
19-e "s/DATABASE_PASSWORD/$password/" \
20-e "s/DATABASE_HOST/$host/" \
21-e "s/DATABASE_NAME/$database/" \
22$hooksdir/local_settings-template.py > local_settings.py
23chown www-data local_settings.py
24
25ensemble-log "Syncing and migration database (if necessary)."
26cd ..
27export VIRTUALENVS_PATH=/opt/open-goal-tracker/virtualenvs
28fab manage:'syncdb --noinput'
29fab manage:'migrate'
30chown -R www-data .
31
32ensemble-log "Setting up the wsgi alias."
33# XXX Use a separate lighttpd or similar for serving static content.
34echo 'Alias /site_media/ /opt/open-goal-tracker/current/media-root-dev/\nWSGIScriptAlias / /opt/open-goal-tracker/current/ogt_project/apache/django.wsgi' >> /etc/apache2/httpd.conf
35service apache2 restart
036
=== added file 'ogt_project/ensemble_deploy/ogt/hooks/install'
--- ogt_project/ensemble_deploy/ogt/hooks/install 1970-01-01 00:00:00 +0000
+++ ogt_project/ensemble_deploy/ogt/hooks/install 2011-09-12 20:54:36 +0000
@@ -0,0 +1,36 @@
1#!/bin/bash
2set -eux # -x for verbose logging to ensemble debug-log
3
4# XXX Resetting PYTHONPATH to avoid package dependency issues with python2.6
5# (which is required by libapache2, even though unused).
6ensemble-log "Resetting PYTHONPATH."
7export PYTHONPATH=
8
9ensemble-log "Upgrading machine."
10apt-get update
11apt-get -y upgrade
12
13ensemble-log "Installing required packages via apt-get."
14apt-get -y install apache2 libapache2-mod-wsgi bzr fabric python-virtualenv python-psycopg2
15
16ensemble-log "Pulling open-goal-tracker into /opt/open-goal-tracker/current"
17rm -rf /opt/open-goal-tracker
18mkdir -p /opt/open-goal-tracker
19cd /opt/open-goal-tracker
20umask 022
21
22# Switch to trunk/release branch.
23bzr branch lp:~michael.nelson/open-goal-tracker/ensemble_deploy current
24
25ensemble-log "Creating the virtualenv in /opt/open-goal-tracker/virtualenvs"
26mkdir virtualenvs
27cd current
28export VIRTUALENVS_PATH=/opt/open-goal-tracker/virtualenvs
29fab ensure_virtualenv
30cd ..
31chown -R ubuntu:www-data current
32
33# Download any 3rd party static medial that we need.
34fab install_local_media_libraries
35
36ensemble-log "Finished install."
037
=== added file 'ogt_project/ensemble_deploy/ogt/hooks/local_settings-template.py'
--- ogt_project/ensemble_deploy/ogt/hooks/local_settings-template.py 1970-01-01 00:00:00 +0000
+++ ogt_project/ensemble_deploy/ogt/hooks/local_settings-template.py 2011-09-12 20:54:36 +0000
@@ -0,0 +1,14 @@
1DATABASES = {
2 'default': {
3 'ENGINE': 'django.db.backends.postgresql_psycopg2',
4 'NAME': 'DATABASE_NAME',
5 'PASSWORD': 'DATABASE_PASSWORD',
6 'USER': 'DATABASE_USER',
7 'HOST': 'DATABASE_HOST',
8 }
9 }
10
11TEMPLATE_DIRS = (
12 '/opt/open-goal-tracker/current/ogt_project/templates/',
13 )
14
015
=== added file 'ogt_project/ensemble_deploy/ogt/hooks/start'
--- ogt_project/ensemble_deploy/ogt/hooks/start 1970-01-01 00:00:00 +0000
+++ ogt_project/ensemble_deploy/ogt/hooks/start 2011-09-12 20:54:36 +0000
@@ -0,0 +1,2 @@
1#!/bin/bash
2service apache2 restart
03
=== added file 'ogt_project/ensemble_deploy/ogt/hooks/stop'
--- ogt_project/ensemble_deploy/ogt/hooks/stop 1970-01-01 00:00:00 +0000
+++ ogt_project/ensemble_deploy/ogt/hooks/stop 2011-09-12 20:54:36 +0000
@@ -0,0 +1,3 @@
1#!/bin/bash
2ensemble-log "Stopping apache"
3service apache2 stop
04
=== added file 'ogt_project/ensemble_deploy/ogt/metadata.yaml'
--- ogt_project/ensemble_deploy/ogt/metadata.yaml 1970-01-01 00:00:00 +0000
+++ ogt_project/ensemble_deploy/ogt/metadata.yaml 2011-09-12 20:54:36 +0000
@@ -0,0 +1,10 @@
1ensemble: formula
2name: ogt
3revision: 1
4summary: "Open Goal Tracker"
5description: |
6 Installs the Open Goal Tracker web service and relates it to
7 the standard mysql formula.
8requires:
9 db:
10 interface: pgsql
011
=== modified file 'ogt_project/settings.py'
--- ogt_project/settings.py 2011-06-23 06:30:45 +0000
+++ ogt_project/settings.py 2011-09-12 20:54:36 +0000
@@ -50,3 +50,8 @@
50LOGIN_URL = '/openid/login/'50LOGIN_URL = '/openid/login/'
51LOGIN_REDIRECT_URL = '/'51LOGIN_REDIRECT_URL = '/'
52OPENID_USE_AS_ADMIN_LOGIN = True52OPENID_USE_AS_ADMIN_LOGIN = True
53
54try:
55 from local_settings import *
56except ImportError:
57 pass
5358
=== modified file 'ogt_project/templates/base.html'
--- ogt_project/templates/base.html 2011-06-22 06:35:23 +0000
+++ ogt_project/templates/base.html 2011-09-12 20:54:36 +0000
@@ -6,10 +6,10 @@
6 <link rel="stylesheet" href="{{ MEDIA_URL }}css/blueprint/screen.css" type="text/css" media="screen, projection">6 <link rel="stylesheet" href="{{ MEDIA_URL }}css/blueprint/screen.css" type="text/css" media="screen, projection">
7 <link rel="stylesheet" href="{{ MEDIA_URL }}css/blueprint/print.css" type="text/css" media="print">7 <link rel="stylesheet" href="{{ MEDIA_URL }}css/blueprint/print.css" type="text/css" media="print">
8 <!--[if lt IE 8]><link rel="stylesheet" href="{{ MEDIA_URL }}css/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->8 <!--[if lt IE 8]><link rel="stylesheet" href="{{ MEDIA_URL }}css/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
9 <link type="text/css" href="{{ MEDIA_URL }}css/jquery/smoothness/jquery-ui-1.8.10.custom.css" rel="Stylesheet" />9 <link type="text/css" href="{{ MEDIA_URL }}css/jquery/smoothness/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />
10 <link rel="stylesheet" href="{{ MEDIA_URL }}css/learninggoals.css" type="text/css" media="screen, projection">10 <link rel="stylesheet" href="{{ MEDIA_URL }}css/learninggoals.css" type="text/css" media="screen, projection">
11 <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery/jquery-1.4.4.min.js"></script>11 <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery/jquery-1.4.4.min.js"></script>
12 <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery/jquery-ui-1.8.10.custom.min.js"></script>12 <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery/jquery-ui-1.8.16.custom.min.js"></script>
13 <script type="text/javascript" src="{{ MEDIA_URL }}js/behaviour-sheet.js"></script>13 <script type="text/javascript" src="{{ MEDIA_URL }}js/behaviour-sheet.js"></script>
14 <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.taconite.js"></script>14 <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.taconite.js"></script>
15 <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.form.js"></script>15 <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.form.js"></script>

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: