Table Of Contents

Previous topic

fabfile.py API

Next topic

Test suite

This Page

Reference

Note

This is auto-generated API reference. Don’t expect much from it.

[source] links are most useful.

Warning

django-fab-deploy is still at early stages of development and API may change in future.

Django

fab_deploy.django_commands.migrate(params='', do_backup=True)[source]

Runs migrate management command. Database backup is performed before migrations if do_backup=False is not passed.

fab_deploy.django_commands.manage(*args, **kwargs)[source]

Runs django management command. Example:

fab manage:createsuperuser
fab_deploy.django_commands.syncdb(params='')[source]

Runs syncdb management command.

fab_deploy.django_commands.test(*args, **kwargs)[source]

Runs ‘runtests.sh’ script from project root. Example runtests.sh content:

#!/bin/sh

default_tests='accounts forum firms blog'
if [ $# -eq 0 ]
then
    ./manage.py test $default_tests --settings=test_settings
else
    ./manage.py test $* --settings=test_settings
fi

Deployment

fab_deploy.deploy.full_deploy()[source]

Prepares server and deploys the project.

fab_deploy.deploy.deploy_project()[source]

Deploys project on prepared server.

fab_deploy.deploy.make_clone()[source]

Creates repository clone on remote server.

fab_deploy.deploy.update_django_config(restart=True)[source]

Updates config.py on server (using config.server.py)

fab_deploy.deploy.up(branch=None)[source]

Runs vcs up or checkout command on server and reloads mod_wsgi process.

fab_deploy.deploy.setup_web_server()[source]

Sets up a web server (apache + nginx).

fab_deploy.deploy.push(*args, **kwargs)[source]

Run it instead of your VCS push command.

The following strings are allowed as positional arguments:

  • ‘notest’ - don’t run tests
  • ‘syncdb’ - run syncdb before code reloading
  • ‘migrate’ - run migrate before code reloading
  • ‘pip_update’ - run virtualenv.pip_update before code reloading
  • ‘norestart’ - do not reload source code

Keyword arguments:

  • before_restart - callable to be executed after code uploading but before the web server reloads the code.

Customization example can be found here.

fab_deploy.deploy.undeploy(confirm=True)[source]

Shuts site down. This command doesn’t clean everything, e.g. user data (database, backups) is preserved.

fab_deploy.system.create_linux_account(*args, **kwargs)[source]

Creates linux account, setups ssh access and pip.conf file.

fab_deploy.system.ssh_add_key(pub_key_file)[source]

Adds a ssh key from passed file to user’s authorized_keys on server.

fab_deploy.system.install_sudo(*args, **kwargs)[source]

Installs sudo on server.

Virtualenv/pip

fab_deploy.virtualenv.pip(*args, **kwargs)[source]

Runs pip command

fab_deploy.virtualenv.pip_install(*args, **kwargs)[source]

Installs pip requirements listed in <PIP_REQUIREMENTS_PATH>/<file>.txt file.

fab_deploy.virtualenv.pip_update(*args, **kwargs)[source]

Updates pip requirements listed in <PIP_REQUIREMENTS_PATH>/<file>.txt file.

fab_deploy.virtualenv.pip_setup_conf()[source]

Sets up pip.conf file

MySQL

fab_deploy.mysql.mysql_execute(sql, user=None, password=None)[source]

Executes passed sql command using mysql shell.

fab_deploy.mysql.mysql_install(*args, **kwargs)[source]

Installs mysql.

fab_deploy.mysql.mysql_create_db()[source]

Creates an empty mysql database.

fab_deploy.mysql.mysqldump(*args, **kwargs)[source]

Runs mysqldump. Result is stored at <env>/var/backups/

Working with crontab

fab_deploy.crontab.crontab_set(content)[source]

Sets crontab content

fab_deploy.crontab.crontab_add(content, marker=None)[source]

Adds line to crontab. Line can be appended with special marker comment so it’ll be possible to reliably remove or update it later.

fab_deploy.crontab.crontab_show()[source]

Shows current crontab

fab_deploy.crontab.crontab_remove(marker)[source]

Removes a line added and marked using crontab_add.

fab_deploy.crontab.crontab_update(content, marker)[source]

Adds or updates a line in crontab.

Web servers

fab_deploy.apache.touch(wsgi_file=None)[source]

Reloads source code by touching the wsgi file.

fab_deploy.nginx.nginx_install(*args, **kwargs)[source]

Installs nginx.

fab_deploy.nginx.nginx_setup(*args, **kwargs)[source]

Updates nginx config and restarts nginx.