Created
September 2, 2012 00:40
-
-
Save mostlymeta/3592554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fabconf.py | |
import os | |
import time | |
from fabric.api import * | |
from fabric.contrib import django | |
django.settings_module('mostlymeta.settings') | |
from django.conf import settings | |
env.fab_root = os.path.dirname(__file__) | |
env.template_dir = os.path.join(env.fab_root, 'templates') | |
env.project_name = 'mostlymeta' | |
env.remote_rsync_root = '/opt/' | |
env.root = '/opt/%(project_name)s' % env | |
env.env_root = '/opt/env' | |
env.env_path = '%(env_root)s/%(project_name)s' % env | |
env.user = 'ubuntu' | |
env.key_filename = '/Users/msilvera/aws_keypairs/mostlymeta_keypair.pem' | |
env.push_dir = '/tmp/%(project_name)s' % env | |
env.media_root = '/opt/%(project_name)s-media/' % env | |
env.static_root = '/opt/%(project_name)s/static/' % env | |
env.domain = 'mostlymeta.com' | |
env.repo = 'git@github.com:mostlymeta/mostlymeta.git' | |
env.aws_access_key_id = 'AKIAIISLSN2X75PAM7DQ' | |
env.aws_secret_access_key = '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' | |
env.ec2_region = 'us-east-1a' | |
env.ec2_ami = 'ami-ac9943c5' | |
env.security_groups = ['default', 'django'] | |
env.ec2_keypair = 'mostlymeta_keypair' | |
env.ec2_instance_type = 'm1.small' | |
env.ec2_volume_size = 10 | |
env.ec2_volume_attachment = '/dev/sdh' | |
env.connection_attempts = 3 | |
# applications | |
env.role_applications = { | |
'www': ['apache', 'app', 'coffeescript', 'less', 'memcached', 'nginx', 'nodejs', 'ssh', 'system', 'virtualenv' ], | |
'db': ['app', 'mysql', 'ssh', 'system', 'virtualenv'], | |
} | |
env.applications = { | |
'app': { | |
'actions': { | |
'syncdb': 'source %(env_path)s/bin/activate; %(root)s/manage.py syncdb --noinput', | |
'migrate': 'source %(env_path)s/bin/activate; %(root)s/manage.py migrate core --noinput', | |
'collect_static': 'source %(env_path)s/bin/activate; %(root)s/manage.py collectstatic --noinput', | |
'clone': ['mkdir -p %(root)s', 'git clone %(repo)s %(root)s'], | |
'pull': 'cd %(root)s; git pull', | |
}, | |
}, | |
'system': { | |
'actions': { | |
'install': [ | |
'mkdir -p /vol', | |
'mkfs.xfs /dev/xvdh', | |
'mount -a', | |
], | |
'update': 'apt-get -y update', | |
}, | |
'files': ['/etc/fstab',], | |
'packages': ['build-essential', 'python-dev', 'python-setuptools', 'unzip', 'git-core', 'gcc', 'binutils', 'curl', 'python-egenix-mxdatetime', 'xfsprogs','libjpeg62', 'libjpeg62-dev', 'zlib1g-dev', 'libfreetype6', 'libfreetype6-dev', 'checkinstall', 'python-software-properties', 'libmysqlclient-dev'], | |
}, | |
'apache': { | |
'actions': { | |
'reload': 'invoke-rc.d apache2 reload', | |
'restart': 'invoke-rc.d apache2 restart', | |
'start': 'invoke-rc.d apache2 start', | |
'stop': 'invoke-rc.d apache2 stop', | |
'touch': 'touch /etc/apache2/django_app.wsgi', | |
}, | |
'files': ['/etc/apache2/apache2.conf', '/etc/apache2/django_app.wsgi'], | |
'packages': ['apache2', 'libapache2-mod-wsgi', 'apache2.2-common', 'apache2-mpm-prefork', 'apache2-utils', 'libexpat1', 'ssl-cert', 'apache2-prefork-dev','libgeoip1',], | |
}, | |
'coffeescript': { | |
'actions': { | |
'install': 'npm -g install coffee-script' | |
} | |
}, | |
'less': { | |
'actions': { | |
'install': 'npm -g install less' | |
} | |
}, | |
'memcached': { | |
'files': ['/etc/memcached.conf'], | |
'actions': { | |
'restart': 'invoke-rc.d memcached restart', | |
'start': 'invoke-rc.d memcached start', | |
'stop': 'invoke-rc.d memcached stop', | |
}, | |
'packages': ['memcached', 'libmemcache-dev'], | |
}, | |
'mysql': { | |
'files': ['/etc/fstab'], | |
'packages': ['mysql-server'], | |
'actions': { | |
'install': [ | |
'mkdir /vol/etc /vol/lib /vol/log', | |
'mv /etc/mysql /vol/etc/', | |
'mv /var/lib/mysql /vol/lib/', | |
'mv /var/log/mysql /vol/log/', | |
'mkdir /etc/mysql', | |
'mkdir /var/lib/mysql', | |
'mkdir /var/log/mysql', | |
'mount -a', | |
], | |
'restart': 'service mysql restart', | |
'start': 'service mysql start', | |
'stop': 'service mysql stop', | |
}, | |
}, | |
'nodejs': { | |
'packages': ['nodejs', 'npm'], | |
}, | |
'nginx': { | |
'files': ['/etc/nginx/nginx.conf', '/etc/nginx/htpasswd'], | |
'packages': ['nginx',], | |
'actions': { | |
'restart': 'invoke-rc.d nginx restart', | |
'start': 'invoke-rc.d nginx start', | |
'stop': 'invoke-rc.d nginx stop', | |
}, | |
}, | |
'ssh': { | |
'actions': { | |
'install': ['chmod 0644 ~/.ssh/authorized_keys', 'chmod 0644 ~/.ssh/id_rsa', 'chmod 0644 /root/.ssh/authorized_keys', 'chmod 0644 /root/.ssh/id_rsa'], | |
}, | |
'files': ['~/.ssh/authorized_keys', '~/.ssh/id_rsa', '~/.ssh/id_rsa.pub', '/root/.ssh/authorized_keys', '/root/.ssh/id_rsa', '/root/.ssh/id_rsa.pub'], | |
}, | |
'virtualenv': { | |
'actions': { | |
'install': [ | |
#'rm -rf %(env_path)s', | |
'mkdir -p %(env_path)s', | |
'easy_install virtualenv', | |
'easy_install virtualenvwrapper', | |
'virtualenv --no-site-packages %(env_path)s', | |
], | |
'update': 'source %(env_path)s/bin/activate; pip install -r %(root)s/requirements.txt', | |
}, | |
}, | |
} | |
env.roledefs = { | |
'www': ['www.mostlymtea.com'], | |
'db': ['db.mostlymeta.com'], | |
} | |
env.host_config = { | |
'db.mostlymeta.com': { | |
'public_ip': '184.73.106.246', | |
'private_ip': '10.254.83.17', | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment