Skip to content

Instantly share code, notes, and snippets.

@nathany
Created March 7, 2011 03:19
Show Gist options
  • Select an option

  • Save nathany/858008 to your computer and use it in GitHub Desktop.

Select an option

Save nathany/858008 to your computer and use it in GitHub Desktop.

Revisions

  1. nathany revised this gist Mar 8, 2011. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion deb.py
    Original file line number Diff line number Diff line change
    @@ -15,4 +15,9 @@ def _prepare():

    def apt(pkg):
    _prepare();
    sudo("apt-get -qqyu install %s" % pkg)
    sudo("apt-get -qqyu install %s" % pkg)

    def has_apt(pkg):
    with settings( hide('warnings','stdout'), warn_only=True):
    result = sudo('dpkg --status %s | grep "ok installed"' % pkg)
    return result.succeeded
  2. nathany created this gist Mar 7, 2011.
    20 changes: 20 additions & 0 deletions Vagrantfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    Vagrant::Config.run do |config|
    # Every Vagrant virtual environment requires a box to build off of.
    config.vm.box = "debian_squeeze_32"

    # The url from where the 'config.vm.box' box will be fetched if it
    # doesn't already exist on the user's system.
    config.vm.box_url = "http://mathie-vagrant-boxes.s3.amazonaws.com/debian_squeeze_32.box"

    # Assign this VM to a host only network IP, allowing you to access it via the IP.
    config.vm.network "33.33.33.10"

    # Forward a port from the guest to the host, which allows for outside
    # computers to access the VM, whereas host only networking does not.
    # config.vm.forward_port "http", 80, 8080

    # Share an additional folder to the guest VM. The first argument is
    # an identifier, the second is the path on the guest to mount the
    # folder, and the third is the path on the host to the actual folder.
    # config.vm.share_folder "v-data", "/vagrant_data", "../data"
    end
    18 changes: 18 additions & 0 deletions deb.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    from fabric.api import *

    def update():
    "Updates Debian/Ubuntu's package list"
    sudo('apt-get -yqq update')

    def upgrade():
    "Perform a safe upgrade"
    update()
    sudo('aptitude -yvq safe-upgrade')

    # @runs_once
    def _prepare():
    sudo("export DEBCONF_TERSE=yes DEBIAN_PRIORITY=critical DEBIAN_FRONTEND=noninteractive")

    def apt(pkg):
    _prepare();
    sudo("apt-get -qqyu install %s" % pkg)
    18 changes: 18 additions & 0 deletions fabfile.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    from fabric.api import *
    from deb import update, upgrade
    import deb

    def vagrant():
    "Use Vagrant for testing"
    env.user = 'vagrant'
    env.hosts = ['33.33.33.10']

    # retrieve the IdentityFile:
    result = local('vagrant ssh_config | grep IdentityFile', capture=True)
    env.key_filename = result.split()[1] # parse IdentityFile

    def host_type():
    run('uname -s')

    def nginx():
    deb.apt('nginx')