Giter Site home page Giter Site logo

burlap's Introduction

Burlap - Fabric commands for simplifying Django deployment

Overview

Implements several modules containing Fabric commands for performing common system administration tasks for Django web applications, such as:

  • application code compression, upload, and installation
  • Apache configuration
  • database (PostgreSQL and MySQL) creation, schema migration, and custom SQL execution
  • Python package caching, upload, and installation
  • user creation
  • configuration of multiple deployment roles (e.g. development, staging and production)

My general philosophy behind this project is if I have to manually SSH into a server to modify configuration files, I'm probably doing something wrong.

To increase maintainability and reliability of production systems, all configuration should be represented in a version-controlled system and be deployed via automated methods.

To that end, I've created this project to organize the dozens of Fabric commands I've written over the years to help deploy Django sites.

It's not comprehensive, and only covers the platforms I've personally used, which is primarily an Apache web server with a PostgreSQL or Amazon RDS hosted MySQL database backend.

Although many modules in this package can be used for non-Django applications, it largely assumes a basic Django setup, and expects to find a Django settings module containing database credentials and static media lists.

Installation

pip install burlap

Usage

  1. CD to a directory on your computer where you want to start your project and then run:
burlap skel --name=<project name>

This will create a structure like...

  1. Create your application code and test with Django's dev server.
  2. Prepare remote host for deployment.

Allocate your production environment by setting up the physical server or creating a VPS.

Populate your settings.yaml. At minimum it would have hosts, key_filename, and user.

hosts: [myserver.mydomain.com]
user: sys-user
key_filename: roles/prod/mydomain.pem

If you need to generate pub/pem files for passwordless SSH access, run:

fab prod user.generate_keys

Ensure the filename of the *.pem file matches the key_filename in your settings.yaml.

If you just created a fresh server and have password SSH access and need to configure passwordless access, run:

fab prod user.passwordless:username=<username>,pubkey=<path/to/yourdomain.pub>

Confirm you have passwordless access by running:

fab prod shell

If you have an active shell prompt on the remote host and weren't prompted for a password, you're ready to deploy.

  1. Deploy your code.
fab prod tarball.create tarball.deploy
  1. Prepare your PIP cache.

List all your Python packages in pip-requirements.txt and then run:

fab prod pip.update

This will download, but not install, all your packages into a local cache. We do this to prevent network latency or timeouts from interferring with our deployment. Note, if you have multiple roles you're deploying to, you can update them all in parallel by running this command for each role in separate terminals. This can save quite a bit of time if you have many packages.

  1. Install packages.
fab prod pip.install

This will rsync all your cached packages up to the host, create a virtual environment and install the packages.

burlap's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.