Major development Vagrantfile cleanup + enable vagrant-cachier
This commit is contained in:
parent
5a48128dcf
commit
7a069957d7
3 changed files with 137 additions and 90 deletions
135
development/Vagrantfile
vendored
135
development/Vagrantfile
vendored
|
@ -1,111 +1,84 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
def local_apt_cache(box_name)
|
||||
cache_dir = File.join(File.expand_path('~/.vagrant.d'),
|
||||
'cache',
|
||||
'apt',
|
||||
box_name)
|
||||
partial_dir = File.join(cache_dir, 'partial')
|
||||
FileUtils.mkdir_p(partial_dir) unless File.exists? partial_dir
|
||||
cache_dir
|
||||
require 'pathname'
|
||||
BASE_URL = 'http://dl.dropbox.com/u/13510779'
|
||||
LAST_RELEASE_DATE = '2013-05-06'
|
||||
LOCAL_BOXES_PATH = Pathname('../boxes/output').expand_path
|
||||
def lxc_box_url(release_name)
|
||||
file_name = "lxc-#{release_name}-amd64-#{LAST_RELEASE_DATE}.box"
|
||||
local_box_file = LOCAL_BOXES_PATH.join(file_name)
|
||||
|
||||
local_box_file.exist? ?
|
||||
local_box_file.to_s :
|
||||
"#{BASE_URL}/#{file_name}"
|
||||
end
|
||||
|
||||
def local_gem_cache(box_name)
|
||||
cache_dir = File.join(File.expand_path('~/.vagrant.d'),
|
||||
'cache',
|
||||
'gems',
|
||||
'source',
|
||||
box_name)
|
||||
FileUtils.mkdir_p(cache_dir) unless File.exists? cache_dir
|
||||
cache_dir
|
||||
end
|
||||
BOXES = {
|
||||
precise: {
|
||||
lxc_url: lxc_box_url('precise'),
|
||||
vbox_url: 'http://files.vagrantup.com/precise64.box'
|
||||
},
|
||||
quantal: {
|
||||
lxc_url: lxc_box_url('quantal'),
|
||||
vbox_url: 'https://github.com/downloads/roderik/VagrantQuantal64Box/quantal64.box'
|
||||
},
|
||||
raring: {
|
||||
lxc_url: lxc_box_url('raring'),
|
||||
vbox_url: 'http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-amd64-vagrant-disk1.box'
|
||||
},
|
||||
squeeze: {
|
||||
vbox_url: 'http://f.willianfernandes.com.br/vagrant-boxes/DebianSqueeze64.box'
|
||||
},
|
||||
wheezy: {
|
||||
lxc_url: lxc_box_url('wheezy'),
|
||||
},
|
||||
sid: {
|
||||
lxc_url: lxc_box_url('sid'),
|
||||
}
|
||||
}
|
||||
|
||||
# Required to make sure vagrant picks it up during development
|
||||
Vagrant.require_plugin 'vagrant-lxc'
|
||||
Vagrant.require_plugin 'vagrant-cachier'
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.synced_folder "../", "/vagrant", id: 'vagrant-root', nfs: true
|
||||
|
||||
config.vm.define :vbox do |vb_config|
|
||||
vb_config.vm.network :private_network, ip: "192.168.50.33"
|
||||
vb_config.vm.box = 'quantal64'
|
||||
vb_config.vm.box_url = "https://github.com/downloads/roderik/VagrantQuantal64Box/quantal64.box"
|
||||
ip_suffix = 30
|
||||
BOXES.each do |box_name, box_config|
|
||||
config.vm.define(box_name.to_sym) do |vm_config|
|
||||
vm_config.vm.network :private_network, ip: "192.168.50.#{ip_suffix += 1}"
|
||||
vm_config.vm.box = "#{box_name}64"
|
||||
|
||||
if box_config[:vbox_url]
|
||||
vm_config.vm.provider :virtualbox do |vb, vb_config|
|
||||
vb_config.vm.box_url = box_config[:vbox_url]
|
||||
vb_config.vm.hostname = 'vbox'
|
||||
|
||||
vb_config.vm.provider :virtualbox do |vb|
|
||||
# Configure VM to use 1.5gb of ram and 2 cpus
|
||||
vb.customize [
|
||||
"modifyvm", :id,
|
||||
"--memory", '1536',
|
||||
"--cpus", '2'
|
||||
]
|
||||
end
|
||||
|
||||
cache_dir = local_apt_cache(vb_config.vm.box)
|
||||
vb_config.vm.synced_folder cache_dir, "/var/cache/apt/archives", id: "vagrant-apt-cache"
|
||||
|
||||
cache_dir = local_gem_cache(vb_config.vm.box)
|
||||
vb_config.vm.synced_folder cache_dir, "/home/vagrant/gems/cache", id: "vagrant-gem-cache"
|
||||
end
|
||||
|
||||
config.vm.define :precise do |precise|
|
||||
precise.vm.network :private_network, ip: "192.168.50.32"
|
||||
precise.vm.box = 'precise64'
|
||||
precise.vm.hostname = 'vbox'
|
||||
precise.vm.box_url = 'http://files.vagrantup.com/precise64.box'
|
||||
if box_config[:lxc_url]
|
||||
vm_config.vm.provider :lxc do |lxc, lxc_config|
|
||||
lxc_config.vm.box_url = box_config[:lxc_url]
|
||||
lxc_config.vm.hostname = 'lxc-dev-box' unless %w(squeeze wheezy sid).include? box_name.to_s
|
||||
|
||||
precise.vm.provider :virtualbox do |vb|
|
||||
# Configure VM to use 1.5gb of ram and 2 cpus
|
||||
vb.customize [
|
||||
"modifyvm", :id,
|
||||
"--memory", '1536',
|
||||
"--cpus", '2'
|
||||
]
|
||||
end
|
||||
|
||||
cache_dir = local_apt_cache(precise.vm.box)
|
||||
precise.vm.synced_folder cache_dir, "/var/cache/apt/archives", id: "vagrant-apt-cache"
|
||||
|
||||
cache_dir = local_gem_cache(precise.vm.box)
|
||||
precise.vm.synced_folder cache_dir, "/home/vagrant/gems/cache", id: "vagrant-gem-cache"
|
||||
end
|
||||
|
||||
config.vm.define :raring do |raring|
|
||||
raring.vm.network :private_network, ip: "192.168.50.34"
|
||||
raring.vm.box = 'raring64'
|
||||
raring.vm.hostname = 'vbox'
|
||||
raring.vm.box_url = 'http://cloud-images.ubuntu.com/vagrant/raring/current/raring-server-cloudimg-amd64-vagrant-disk1.box'
|
||||
|
||||
raring.vm.provider :virtualbox do |vb|
|
||||
# Configure VM to use 1.5gb of ram and 2 cpus
|
||||
vb.customize [
|
||||
"modifyvm", :id,
|
||||
"--memory", '1536',
|
||||
"--cpus", '2'
|
||||
]
|
||||
end
|
||||
|
||||
cache_dir = local_apt_cache(raring.vm.box)
|
||||
raring.vm.synced_folder cache_dir, "/var/cache/apt/archives", id: "vagrant-apt-cache"
|
||||
|
||||
cache_dir = local_gem_cache(raring.vm.box)
|
||||
raring.vm.synced_folder cache_dir, "/home/vagrant/gems/cache", id: "vagrant-gem-cache"
|
||||
end
|
||||
|
||||
config.vm.define :lxc do |lxc_config|
|
||||
lxc_config.vm.box = 'quantal64'
|
||||
lxc_config.vm.hostname = 'lxc-dev-box'
|
||||
lxc_config.vm.box_url = 'http://dl.dropbox.com/u/13510779/lxc-quantal64-2013-04-21.box'
|
||||
# Uncomment to test boxes built locally:
|
||||
# lxc_config.vm.box_url = '../boxes/output/lxc-quantal64.box'
|
||||
|
||||
lxc_config.vm.provider :lxc do |lxc|
|
||||
# Required to boot nested containers
|
||||
lxc.customize 'aa_profile', 'unconfined'
|
||||
end
|
||||
end
|
||||
|
||||
vm_config.cache.enable :apt
|
||||
vm_config.cache.enable :gem
|
||||
end
|
||||
end
|
||||
|
||||
config.vm.provision :shell, :inline => 'sudo apt-get update'
|
||||
config.vm.provision :shell, :path => 'shell-provisioning/upgrade-kernel'
|
||||
|
||||
config.vm.provision :puppet do |puppet|
|
||||
|
|
37
development/lxc-configs/sid
Normal file
37
development/lxc-configs/sid
Normal file
|
@ -0,0 +1,37 @@
|
|||
###############################################################################
|
||||
# This file has the same configs as the built in /etc/default/lxc on Ubuntu,
|
||||
# we only changed IPs to 10.0.254.* to avoid collision with LXC default 10.0.3.*
|
||||
# which is likely to be running from the host machine
|
||||
###############################################################################
|
||||
|
||||
|
||||
# MIRROR to be used by ubuntu template at container creation:
|
||||
# Leaving it undefined is fine
|
||||
#MIRROR="http://archive.ubuntu.com/ubuntu"
|
||||
# or
|
||||
#MIRROR="http://<host-ip-addr>:3142/archive.ubuntu.com/ubuntu"
|
||||
|
||||
# LXC_AUTO - whether or not to start containers symlinked under
|
||||
# /etc/lxc/auto
|
||||
LXC_AUTO="true"
|
||||
|
||||
# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
|
||||
# containers. Set to "false" if you'll use virbr0 or another existing
|
||||
# bridge, or mavlan to your host's NIC.
|
||||
USE_LXC_BRIDGE="true"
|
||||
|
||||
# If you change the LXC_BRIDGE to something other than lxcbr1, then
|
||||
# you will also need to update your /etc/lxc/lxc.conf as well as the
|
||||
# configuration (/var/lib/lxc/<container>/config) for any containers
|
||||
# already created using the default config to reflect the new bridge
|
||||
# name.
|
||||
# If you have the dnsmasq daemon installed, you'll also have to update
|
||||
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
|
||||
LXC_BRIDGE="lxcbr0"
|
||||
LXC_ADDR="10.0.251.1"
|
||||
LXC_NETMASK="255.255.255.0"
|
||||
LXC_NETWORK="10.0.251.0/24"
|
||||
LXC_DHCP_RANGE="10.0.253.2,10.0.251.254"
|
||||
LXC_DHCP_MAX="253"
|
||||
|
||||
LXC_SHUTDOWN_TIMEOUT=120
|
37
development/lxc-configs/wheezy
Normal file
37
development/lxc-configs/wheezy
Normal file
|
@ -0,0 +1,37 @@
|
|||
###############################################################################
|
||||
# This file has the same configs as the built in /etc/default/lxc on Ubuntu,
|
||||
# we only changed IPs to 10.0.254.* to avoid collision with LXC default 10.0.3.*
|
||||
# which is likely to be running from the host machine
|
||||
###############################################################################
|
||||
|
||||
|
||||
# MIRROR to be used by ubuntu template at container creation:
|
||||
# Leaving it undefined is fine
|
||||
#MIRROR="http://archive.ubuntu.com/ubuntu"
|
||||
# or
|
||||
#MIRROR="http://<host-ip-addr>:3142/archive.ubuntu.com/ubuntu"
|
||||
|
||||
# LXC_AUTO - whether or not to start containers symlinked under
|
||||
# /etc/lxc/auto
|
||||
LXC_AUTO="true"
|
||||
|
||||
# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
|
||||
# containers. Set to "false" if you'll use virbr0 or another existing
|
||||
# bridge, or mavlan to your host's NIC.
|
||||
USE_LXC_BRIDGE="true"
|
||||
|
||||
# If you change the LXC_BRIDGE to something other than lxcbr1, then
|
||||
# you will also need to update your /etc/lxc/lxc.conf as well as the
|
||||
# configuration (/var/lib/lxc/<container>/config) for any containers
|
||||
# already created using the default config to reflect the new bridge
|
||||
# name.
|
||||
# If you have the dnsmasq daemon installed, you'll also have to update
|
||||
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
|
||||
LXC_BRIDGE="lxcbr0"
|
||||
LXC_ADDR="10.0.252.1"
|
||||
LXC_NETMASK="255.255.255.0"
|
||||
LXC_NETWORK="10.0.252.0/24"
|
||||
LXC_DHCP_RANGE="10.0.253.2,10.0.252.254"
|
||||
LXC_DHCP_MAX="253"
|
||||
|
||||
LXC_SHUTDOWN_TIMEOUT=120
|
Loading…
Reference in a new issue