-mezzanine_proj_name: mezzanine_example
+mezzanine_proj_app: mezzanine_example
+mezzanine_proj_name: "{{ mezzanine_proj_app }}"
locale: en_US.UTF-8
database_port: 5432
+- name: create a logs directory
+ file: path="{{ ansible_env.HOME }}/logs" state=directory
- name: check out the repository on the host
git: repo={{ mezzanine_repo_url }} dest={{ mezzanine_proj_path }} accept_hostkey=yes
+- name: install Python requirements globally via pip
+ pip: name={{ item }} state=latest
+ with_items:
+ - pip
+ - virtualenv
+ - virtualenvwrapper
- name: install required python packages
pip: name={{ item }} virtualenv={{ mezzanine_venv_path }}
with_items:
- gunicorn
- setproctitle
- - south
- psycopg2
- django-compressor
- python-memcached
virtualenv={{ mezzanine_venv_path }}
- name: generate the settings file
template: src=local_settings.py.j2 dest={{ mezzanine_proj_path }}/local_settings.py
-- name: sync the database, apply migrations, collect static content
+- name: apply migrations to create the database, collect static content
django_manage:
command: "{{ item }}"
app_path: "{{ mezzanine_proj_path }}"
virtualenv: "{{ mezzanine_venv_path }}"
with_items:
- - syncdb
- migrate
- collectstatic
- name: set the site id
environment:
PATH: "{{ mezzanine_venv_path }}/bin"
PROJECT_DIR: "{{ mezzanine_proj_path }}"
+ PROJECT_APP: "{{ mezzanine_proj_app }}"
WEBSITE_DOMAIN: "{{ live_hostname }}"
- name: set the admin password
script: scripts/setadmin.py
environment:
PATH: "{{ mezzanine_venv_path }}/bin"
PROJECT_DIR: "{{ mezzanine_proj_path }}"
+ PROJECT_APP: "{{ mezzanine_proj_app }}"
ADMIN_PASSWORD: "{{ admin_pass }}"
- name: set the gunicorn config file
template: src=gunicorn.conf.py.j2 dest={{ mezzanine_proj_path }}/gunicorn.conf.py
- libjpeg-dev
- libpq-dev
- memcached
- - nginx
+ - postgresql
- python-dev
- python-pip
- python-psycopg2
upstream {{ mezzanine_proj_name }} {
- server 127.0.0.1:{{ mezzanine_gunicorn_port }};
+ server unix:{{ mezzanine_proj_path }}/gunicorn.sock fail_timeout=0;
}
server {
-[group: {{ mezzanine_proj_name }}]
-programs=gunicorn_{{ mezzanine_proj_name }}
-
-[program:gunicorn_{{ mezzanine_proj_name }}]
-command={{ mezzanine_venv_path }}/bin/gunicorn_django -c gunicorn.conf.py -p gunicorn.pid
+[program:{{ mezzanine_gunicorn_procname }}]
+command={{ mezzanine_venv_path }}/bin/gunicorn -c gunicorn.conf.py -p gunicorn.pid {{ mezzanine_proj_app }}.wsgi:application
directory={{ mezzanine_proj_path }}
user={{ mezzanine_user }}
autostart=true
+stdout_logfile = /home/{{ mezzanine_user }}/logs/{{ mezzanine_proj_name }}_supervisor
autorestart=true
redirect_stderr=true
environment=LANG="{{ locale }}",LC_ALL="{{ locale }}",LC_LANG="{{ locale }}"
mezzanine_python: "{{ mezzanine_venv_path }}/bin/python"
mezzanine_manage: "{{ mezzanine_python }} {{ mezzanine_proj_path }}/manage.py"
mezzanine_num_workers: "multiprocessing.cpu_count() * 2 + 1"
+mezzanine_gunicorn_procname: gunicorn_mezzanine
# Assumes two environment variables
#
# PROJECT_DIR: the project directory (e.g., ~/projname)
+# PROJECT_APP: name of the project app
# ADMIN_PASSWORD: admin user's password
import os
proj_dir = os.path.expanduser(os.environ['PROJECT_DIR'])
sys.path.append(proj_dir)
-os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
-
-
-from mezzanine.utils.models import get_user_model
+proj_app = os.environ['PROJECT_APP']
+os.environ['DJANGO_SETTINGS_MODULE'] = proj_app + '.settings'
+import django
+django.setup()
+from django.contrib.auth import get_user_model
User = get_user_model()
u, _ = User.objects.get_or_create(username='admin')
u.is_staff = u.is_superuser = True
# A script to set the site domain
# Assumes two environment variables
#
-# PROJECT_DIR: the project directory (e.g., ~/projname)
# WEBSITE_DOMAIN: the domain of the site (e.g., www.example.com)
-
+# PROJECT_DIR: root directory of the project
+# PROJECT_APP: name of the project app
import os
import sys
proj_dir = os.path.expanduser(os.environ['PROJECT_DIR'])
sys.path.append(proj_dir)
-os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
+proj_app = os.environ['PROJECT_APP']
+os.environ['DJANGO_SETTINGS_MODULE'] = proj_app + '.settings'
+import django
+django.setup()
from django.conf import settings
from django.contrib.sites.models import Site
-
domain = os.environ['WEBSITE_DOMAIN']
Site.objects.filter(id=settings.SITE_ID).update(domain=domain)
Site.objects.get_or_create(domain=domain)
-