Runs the followintg sub-tasks, which can be run separately:
- create_user
- create_db
- upload_local_public_key
- generate_keypair
- show_public_key
- setup_virtualenv
Deploy a project, doing all the required magick.
Deploy, replace remote db and uploaded media with local copies.
Run arbitrary Django management command.
Kill Django instance, which should be restarted by supervisor process.
Set settings/_local.py value.
- host should be accessible through SSH
- local Git repository's remote
origin
with branchmaster
is used by default to update the project code on the host - we use PostgreSQL with admin user
postgres
, db name defaults toenv.user
- remote user is in the main group of the same name
env.poweruser
has full sudo privileges, defaults to the running user's name and is used to create user, db, chown operations, etcenv.type
holds the host type and defaults toproduction
and is used for choosing Django settings and PIP requirements files
- Basic development packages (gcc, autotools, openssl, zlib, etc)
- Some supervisor program to run Django WSGI process
- PostgreSQL server (matching local version, if you want to use custom dump files)
- Git, SVN, Mercurial, cURL
- local db access is granted to
env.user
(~/.pgpass might help) - remote db access is granted to the system user with the same name
from fabric.api import env
from webdev_fab import set_project_defaults
from webdev_fab.tasks import *
from webdev_fab.tasks.django import *
env.user = 'projname'
# A shortcut to set 'db', 'db_user', 'group' and 'project' values equal
# to 'user', which are required for this tasks to function
set_project_defaults(env.user)
# Everything else is optional
# Default list of hosts to run tasks on
if not env.hosts:
env.hosts = ['somehost.yourteam.com:2222']
# Fabric can can utilize some ~/.ssh/config shortcuts
env.use_ssh_config = True
# The user with full sudo privileges, defaults to the user running 'fab'
env.poweruser = 'privilegedusername'
# A group to own project/tmp directory with fcgi socket/pid files, defaults
# to 'nginx'
env.webserver_group = 'www-data'
fab -l
fab provision
fab local_to_remote
git commit -a -m "Some changes" && git push && fab deploy
This project is used in a custom django basic project template and Chef/knife-solo based django-kitchen.