-
-
Save pierrejean-coudert/2225552 to your computer and use it in GitHub Desktop.
Vagrant Fabric experiment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import * | |
from deb import update, upgrade | |
import deb | |
def vagrant(): | |
"Use Vagrant for testing" | |
env.user = 'vagrant' | |
env.hosts = ['127.0.0.1:2222'] | |
# retrieve the IdentityFile: | |
result = local('vagrant ssh-config | grep IdentityFile', capture=True) | |
print result | |
env.key_filename = result.lstrip('IdentityFile').strip() # parse IdentityFile | |
print env.key_filename | |
def host_type(): | |
run('uname -s') | |
def nginx(): | |
deb.apt('nginx') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant::Config.run do |config| | |
config.vm.define :djangovm do |django_config| | |
# Every Vagrant virtual environment requires a box to build off of. | |
django_config.vm.box = "lucid64" | |
# The url from where the 'config.vm.box' box will be fetched if it | |
# doesn't already exist on the user's system. | |
django_config.vm.box_url = "http://files.vagrantup.com/lucid64.box" | |
# Forward a port from the guest to the host, which allows for outside | |
# computers to access the VM, whereas host only networking does not. | |
django_config.vm.forward_port 80, 8080 | |
django_config.vm.forward_port 8000, 8001 | |
# Enable provisioning with chef solo, specifying a cookbooks path (relative | |
# to this Vagrantfile), and adding some recipes and/or roles. | |
# | |
# django_config.vm.provision :chef_solo do |chef| | |
# chef.cookbooks_path = "cookbooks" | |
# chef.add_recipe "apt" | |
# | |
# # You may also specify custom JSON attributes: | |
# chef.json = { :mysql_password => "foo" } | |
# end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment