fabric

Activate a virtualenv via fabric as deploy user

I want to run my fabric script locally, which will in turn, log into my server, switch user to deploy, activate the projects .virtualenv, which will change dir to the project and issue a git pull. def git_pull(): sudo('su deploy') # here i need to switch to the virtualenv run('git pull') I typically use the workon command ...

Activate virtualenv via os.system()

Hey all, I'm writing a Python-based shell script to boilerplate a Django app with virtualenv, pip, and fabric. Should be straightforward enough, but it appears that I'm not able to activate and run commands in the virtualenv through the shell script. os.system('virtualenv %s --no-site-packages' % project_name) os.system('source %s/bin/...

Fabric error No handlers could be found for logger "paramiko.transport"

I'm not sure why I'm getting this error that's terminating my connection. I updated paramiko-1.7.6 from 1.7.5 via easy_install. I'm trying to setup Fabric to upload my Django app to my server. The error seems to be happening when I attempt to make a backup of the existing app directory: def backup_current_install(): now = datetime.da...

Why does PIP install of python-couchdb experimental branch from SVN fail?

I'm setting up a Fabric/virtualenv/pip automated deployment for a project and I need to install the latest experimental branch of python-couchdb. Naturally, I stick it in my pip requirements file, like so: -e svn+http://couchdb-python.googlecode.com/svn/branches/experimental/httplib@195#egg=CouchDB-dev_r195 However, when I run my dep...

Fabric error: Fatal error: local() encountered an error (return code 2) while executing 'git commit -m 'message'

I'm trying to setup a fabfile to deploy my Django app. I can't figure out why I'm getting this error: Fatal error: local() encountered an error (return code 2) while executing 'git commit -m 'changed settings for prodserver' $ fab create_branch_deploy_to_prodserver [localhost] run: git checkout prodserver_server [localhost] run: git me...

howto to create mysql database from fabric dynamically

Is it possible to create mysql database from fabric dynamically. This seems like it gets stuck at the password prompt run('mysql -u %s -p %s -h %s ' % (env.mysqluser, env.mysqlpassword, env.mysqlhost), pty=True) run('CREATE DATABASE %s; ' % (dataname), pty=True) run('exit', pty=True) ...

How to add a variable to the module I import from?

What I want to do is something like this: template.py def dummy_func(): print(VAR) # more functions like this to follow fabfile.py # this gets called by fabric (fabfile.org) # safe to think of it as ant build.xml import template template.VAR = 'some_val' from template import * Namely I have a template module other modules shoul...

Installing Fabric On Windows (Error No Module Called Readline)

I'm trying to use the Fabric 0.1.1 deploy tool (http://docs.fabfile.org/) on Windows and we're running into an issue with the readline module. I've been through various threads but can't seem to solve the issue. It's important because we can't deploy applications from Windows based machines. C:\Documents and Settings\dev\Desktop\deplo...

fabric postgresql create database

What would be equivalent of this in postgresql run('echo "CREATE DATABASE %s;"|mysql --batch --user=%s --password=%s --host=%s' % (dataname, env.mysqluser, env.mysqlpassword, env.mysqlhost), pty=True) The above works fine for creating mysql database, but how would you create one in postgresql without getting stuck at password prompt. ...

How to make Fabric execution follow the env.hosts list order?

I have the following fabfile.py: from fabric.api import env, run host1 = '192.168.200.181' host2 = '192.168.200.182' host3 = '192.168.200.183' env.hosts = [host1, host2, host3] def df_h(): run("df -h | grep sda3") And I get the following output: [192.168.200.181] run: df -h | grep sda3 [192.168.200.181] out: /dev/sda3 ...

How to make Fabric ignore offline hosts in the env.hosts list?

This is related to my previous question, but a different one. I have the following fabfile: from fabric.api import * host1 = '192.168.200.181' offline_host2 = '192.168.200.199' host3 = '192.168.200.183' env.hosts = [host1, offline_host2, host3] env.warn_only = True def df_h(): with settings(warn_only=True): run("df -h ...

'Invalid Key' error from Paramiko

I'm trying to set up Fabric for deploying my Python web application and Paramiko is barfing on my private RSA key. I had been using my key successfully for 6 months, so I know it's good. In case having a passphrase was the problem, I just made a new key with no passphrase and still get the error. Help? ...

Multiple django-apps on python path or in project

I have a decent sized django project and when I originally built it I kept all the apps in an apps folder under the project root. project/apps/articles, project/apps/video etc. After a while I decided to move to best practices and make them more reusable so I moved them into their own separate apps then symlink'd them to my python path....

fabric python install problem

Just installed fabric, trying to use to same fabfile that works on a different server, getting this error here: Traceback (most recent call last): File "/var/lib/python-support/python2.6/fabric.py", line 1211, in main load(fabfile, fail='warn') File "/var/lib/python-support/python2.6/fabric.py", line 467, in load execfile(fi...

Python Fabric: How to answer to keyboard input ?

I would like to automate the response for some question prompted by some programs, like mysql prompting for a password, or apt asking for a 'yes' or ... when I want to rebuild my haystack index with a ./manage.py rebuild_index. For MySQL, I can use the --password= switch, and I'm sure that apt has a 'quiet' like option. But how can I p...

How to set target hosts in Fabric file

I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile: def deploy_2_dev(): deploy('dev') def deploy_2_staging(): deploy('staging') def deploy_2_prod(): deploy('prod') def deploy(server): print 'env.hosts:', env.hosts env.hosts = [server] print 'env.hosts:', env.hosts S...

django fabric syncdb

How would you run this django command to syncdb with fabric automatically. python manage.py syncdb --settings="app.settings.test" if tried to do run, it gets stuck at the "Do you want to create superuser account", can it passed as yes and login information with it. run('python manage.py syncdb --settings="app.settings.%s"' % name...

fabric password

Every time fabric runs, it asks for root password, can it be sent along same for automated proposes. fab staging test ...

How do you use pip, virtual_env and Fabric to handle deployement?

What are your settings, your tricks, and above all, your work flow? These tools are great but they are still no best practices attached to their usage, so I don't know what is the most efficient way to use them. Do you use pip bundles or always download? Do you set up Apache/Cherokee/MySQL by hand or do you have a script for than. D...

How to setup Continuous Integration and Continuous Deployment for Django projects?

Hello, I am researching about how to set up CI and continuous deployment for a small team project for a Django based web application. Here are needs: Developer check in the code into a hosted SVN server (unfuddle.com) A CI server detects new checkin, check out the source, build, run functional tests. If tests all passed, deploy the cod...