Skip to content

Instantly share code, notes, and snippets.

@DanLipsitt
Forked from nathany/Vagrantfile
Created March 1, 2012 01:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanLipsitt/1946531 to your computer and use it in GitHub Desktop.
Save DanLipsitt/1946531 to your computer and use it in GitHub Desktop.
Vagrant Fabric experiment
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)
def has_apt(pkg):
with settings( hide('warnings','stdout'), warn_only=True):
result = sudo('dpkg --status %s | grep "ok installed"' % pkg)
return result.succeeded
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')
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment