Public
snipts » fabric
showing 1-8 of 8 snipts for fabric
-
∞ fabric setup for django
# def localhost(): config.fab_hosts = ['localhost'] config.path = '/home/john/saebyn' config.env_path = '/usr/local/pythonenv/' config.env_name = 'SAEBYN-1' config.fab_user = 'john' def local_test(): localhost() local('source $(env_path)/$(env_name)/bin/activate; cd $(path)/website; ./manage.py runserver --settings=local_settings') def test(): """Production server settings""" config.fab_hosts = ['saebyn.info'] config.path = '/home/www/test.saebyn.info' config.fab_user = 'john' config.env_path = '/usr/local/pythonenv/' config.env_name = 'SAEBYN-1' def production(): """Production server settings""" config.fab_hosts = ['saebyn.info'] config.path = '/home/www/saebyn.info' config.fab_user = 'john' config.env_path = '/usr/local/pythonenv/' config.env_name = 'SAEBYN-1' def setup(): """ Setup a fresh virtualenv and install everything we need so it's ready to deploy to """ create_virtualenv() install_requirements() def create_virtualenv(): sudo('mkdir -p $(env_path)') sudo('cd $(env_path); virtualenv $(env_name)') sudo('cd $(env_path); chown -R $(fab_user) $(env_name)') def install_requirements(): """Install the required packages using pip""" run('cd $(env_path)/$(env_name); pip install -E . -r $(path)/requirements.txt') def deploy(): """Deploy the latest version of the site to the server and restart apache""" push_live() migrate() restart_apache() def push_live(): """Rebase 'live' using 'master', push it.""" local('git checkout live') local('git rebase master') local('git push origin live') local('git checkout master') def migrate(): """Run our migrations""" run('source $(env_path)/$(env_name)/bin/activate; cd $(path)/website; python manage.py syncdb --noinput --migrate') def restart_apache(): """Restart the web server""" sudo('/etc/init.d/apache2 restart')
-
∞ use fabric to create a new blog from ghm blog platform
fab create_blog:d=domain,h=localhost,u=dbuser,p=dbpass,db=dbname
-
∞ deploy a project using fabric without committing changes
fab deploy
-
∞ deploy a project using fabric and commit changes
fab deploy:m='my subversion message'
-
∞ run fabric update command within project
fab update
-
∞ common fabric functions for deploying and updating projects
def update(): "Update development MySQL database with production clone." require( 'prod_mysql_host', 'prod_mysql_user', 'prod_mysql_pass', 'prod_mysql_db', 'local_mysql_host', 'local_mysql_user', 'local_mysql_pass', 'local_mysql_db' ) # Run the database dump on the server and store as file. run("mysqldump --user=$(prod_mysql_user) --password=$(prod_mysql_pass) --host $(prod_mysql_host) $(prod_mysql_db) > $(prod_mysql_db).dump") # Download the database dump from the server and store as file. Will be stored as $(prod_mysql_db).dump.$(fab_host). download('$(prod_mysql_db).dump', '$(prod_mysql_db).dump') # On our local workstation, create a fresh instance of the database and import the production dump into it. local(""" `mysql -u$(local_mysql_user) -p$(local_mysql_pass) -h$(local_mysql_host) << EOF DROP DATABASE IF EXISTS $(local_mysql_db); CREATE DATABASE $(local_mysql_db); exit` `mysql -u$(local_mysql_user) -p$(local_mysql_pass) -h$(local_mysql_host) $(local_mysql_db) < $(prod_mysql_db).dump.$(fab_host)` """) def deploy(**kwargs): "Deploy code changes to the production server." # If a message is provided (fab deploy:m='a message'), run an SVN commit, first. if 'm' in kwargs: set(message = kwargs['m']) local("svn ci -m '$(message)'") else: local("echo 'WARNING: running deploy without SVN commit.\n##########'") run("svn update $(prod_dir)")
-
∞ how to set fabric config settings in older versions of fabric
set(fab_hosts = ['production.server.com'])
-
∞ example fabfile for python fabric project
# Load our global function definitions. load('/path/to/fabric_global.py') # Set project server settings. config.fab_hosts = ['production.server.com'] set( fab_user = 'sshuser', fab_host = config.fab_hosts[0], # Shouldn't have to do this, but $(fab_host) doesn't appear to work. prod_dir = '/var/www/vhosts/project.com/httpdocs' # Directory that the production codebase exists in. ) # Set production server MySQL credentials. set( prod_mysql_host = 'localhost', # This will usually be localhost (beacuse it's being run on the server itself) prod_mysql_user = 'dbuser', prod_mysql_pass = 'dbpass', prod_mysql_db = 'dbname' ) # Set local server MySQL credentials. set( local_mysql_host = 'localhost', local_mysql_user = 'locdbuser', local_mysql_pass = 'locdbpass', local_mysql_db = 'locdbname' )



High Performance MySQL