IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » fabric The latest public fabric snipts.

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')
    

    copy | embed

    0 comments - tagged in  posted by saebyn on Oct 18, 2009 at 2:31 p.m. EDT
  • use fabric to create a new blog from ghm blog platform
    fab create_blog:d=domain,h=localhost,u=dbuser,p=dbpass,db=dbname
    

    copy | embed

    0 comments - tagged in  posted by nick on Feb 11, 2009 at 1:14 p.m. EST
  • deploy a project using fabric without committing changes
    fab deploy
    

    copy | embed

    0 comments - tagged in  posted by nick on Feb 04, 2009 at 9:50 p.m. EST
  • deploy a project using fabric and commit changes
    fab deploy:m='my subversion message'
    

    copy | embed

    0 comments - tagged in  posted by nick on Feb 04, 2009 at 9:50 p.m. EST
  • run fabric update command within project
    fab update
    

    copy | embed

    0 comments - tagged in  posted by nick on Feb 04, 2009 at 9:50 p.m. EST
  • 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)")
    

    copy | embed

    0 comments - tagged in  posted by nick on Feb 04, 2009 at 9:49 p.m. EST
  • how to set fabric config settings in older versions of fabric
    set(fab_hosts = ['production.server.com'])
    

    copy | embed

    0 comments - tagged in  posted by nick on Feb 04, 2009 at 9:48 p.m. EST
  • 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'
    )
    

    copy | embed

    0 comments - tagged in  posted by nick on Feb 04, 2009 at 9:47 p.m. EST
Sign up to create your own snipts, or login.