Skip to content

Instantly share code, notes, and snippets.

@harlanbarnes
Created April 24, 2014 22:20
Show Gist options
  • Save harlanbarnes/11271510 to your computer and use it in GitHub Desktop.
Save harlanbarnes/11271510 to your computer and use it in GitHub Desktop.
onsite-vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'lxc'
Vagrant.require_plugin 'vagrant-triggers'
Vagrant.configure("2") do |config|
config.ssh.forward_agent = true
config.vm.provider :virtualbox do |vb, override|
override.vm.box_url = "http://goo.gl/8kWkm"
end
config.vm.box = "precise64_plus_chef"
config.vm.synced_folder ".", "/vagrant", type: "rsync"
config.vm.provider :lxc do |lxc, override|
override.vm.box="precise64"
lxc.customize 'cgroup.memory.limit_in_bytes', '1024M'
end
{ [:up,:provision] => "sudo rake berks_drop" }.each do |command,trigger|
config.trigger.before command, :execute => trigger, :stdout => true, :append_to_path => File.dirname(__FILE__)
end
config.vm.define "server", primary: true do |server|
server.vm.network "forwarded_port", guest: 443, host: 8443
server.vm.provider :virtualbox do |vb,override|
server.vm.network "private_network", ip: "192.168.42.10"
end
server.vm.provider :lxc do |lxc|
server.vm.provision "shell", inline: "/sbin/ip addr add 192.168.42.10/24 dev eth0 || true"
end
$rootcmds = <<-EOF
# setup a pointer to the other VM for comms
echo "192.168.42.10 www.chronotrackserver.com chronotrackserver.com" >> /etc/hosts
echo "192.168.42.20 vagrant-pkg.bazumedia.com" >> /etc/hosts
# Unconditional upgrade to latest
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
apt-get -y install ruby gem rake build-essential
gem install chef --no-rdoc --no-ri
chef-solo -c /vagrant/zero/client.rb -j /vagrant/zero/server.json
EOF
server.vm.provision "shell", inline: $rootcmds
end
config.vm.define "pkg", primary: false do |pkg|
pkg.vm.network "forwarded_port", guest: 443, host: 9443
pkg.vm.provider :virtualbox do |vb,override|
pkg.vm.network "private_network", ip: "192.168.42.20"
end
pkg.vm.provider :lxc do |lxc|
pkg.vm.provision "shell", inline: "/sbin/ip addr add 192.168.42.20/24 dev eth0 || true"
end
$rootcmds = <<-EOF
# setup a pointer to the other VM for comms
echo "192.168.42.10 www.chronotrackserver.com chronotrackserver.com" >> /etc/hosts
echo "192.168.42.20 vagrant-pkg.bazumedia.com" >> /etc/hosts
# Unconditional upgrade to latest
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
apt-get -y install ruby gem rake build-essential
gem install chef --no-rdoc --no-ri
chef-solo -c /vagrant/zero/client.rb -j /vagrant/zero/pkg.json
EOF
pkg.vm.provision "shell", inline: $rootcmds
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment