Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
105 lines (89 sloc) 2.62 KB
Fabric file to deploy the `mini_qa` question-answering program. The
main workflow is one of:
1. `fab first_deploy`: set up the EC2 instance, run tests, push all
code to server
2. `fab deploy`: run tests, and push all code to server
# Standard library
import os
# Third-party libraries
from fabric.api import *
from fabric.contrib.console import confirm
# My libraries
import config
import ec2.ec2 as ec2
env.hosts = ec2.public_dns_names("mini_qa")
env.user = 'ubuntu'
env.key_filename = ["%s/%s.pem" % \
(os.environ["AWS_HOME"], os.environ["AWS_KEYPAIR"])]
def start():
Create an EC2 instance, set it up, and login.
ec2.login("mini_qa", 0)
def first_deploy():
Sets up the initial git repository and other files, then do a
standard deployment.
def setup_instance():
Install all the required software on the remote machine, and configure
# Make sure we're up to date
run("sudo apt-get update")
# git
run("sudo apt-get install -y git-core")
run("git config --global 'Michael Nielsen'")
run("git config --global ''")
run("git config --global core.editor emacs")
run("git config --global checkout")
run("git config --global credential.helper cache")
# emacs
run("sudo apt-get install -y emacs23")
# Python libraries
# Make sure the Python path includes the $HOME directory
run("export PYTHONPATH=$HOME/")
# Python tools
run("sudo apt-get install -y python-dev")
run("sudo apt-get install -y python-setuptools")
run("sudo apt-get install -y ipython")
# Python libraries
run("sudo easy_install BeautifulSoup")
run("sudo easy_install boto")
def clone_repo():
When deploying for the first time, clone the desired GitHub
repository onto the EC2 instance.
run("git clone" % \
def deploy():
Run tests, deploy all code to server, including code not in
code_dir = "/home/ubuntu/"+config.GITHUB_PROJECT_NAME
with cd(code_dir):
run("git pull")
def test():
Run the tests.
def transfer_special_files():
When deploying, transfer files that are not in the repository.
put("", "/home/ubuntu/%s/" %