Skip to content

Instantly share code, notes, and snippets.

Created March 6, 2014 13:09
Show Gist options
  • Save anonymous/9389201 to your computer and use it in GitHub Desktop.
Save anonymous/9389201 to your computer and use it in GitHub Desktop.
VagrantFile of Doom
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Set this to the IP of the Chef server
chefIP = "10.10.80.100"
nodes = {
'rpcs-chef' => [1, 100],
'rpcs-controller' => [1, 103],
'rpcs-compute' => [1, 104],
}
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
if Vagrant.has_plugin?("vagrant-cachier")
# Configure cached packages to be shared between instances of the same base box.
# More info on http://fgrehm.viewdocs.io/vagrant-cachier/usage
config.cache.scope = :box
# If you are using VirtualBox, you might want to use that to enable NFS for
# shared folders. This is also very useful for vagrant-libvirt if you want
# bi-directional sync
config.cache.synced_folder_opts = {
type: :nfs,
# The nolock option can be useful for an NFSv3 client that wants to avoid the
# NLM sideband protocol. Without this option, apt-get might hang if it tries
# to lock files needed for /var/cache/* operations. All of this can be avoided
# by using NFSv4 everywhere. Please note that the tcp option is not the default.
mount_options: ['rw', 'vers=3', 'tcp', 'nolock']
}
# For more information please check http://docs.vagrantup.com/v2/synced-folders/basic_usage.html
end
config.vm.provider "vmware_fusion" do |v, override|
override.vm.box = "precise64"
override.vm.box_url = "http://grahamc.com/vagrant/ubuntu-12.04.2-server-amd64-vmware-fusion.box"
# override.vm.synced_folder ".", "/vagrant", type: "nfs"
# Fusion Performance Hacks
v.vmx["logging"] = "FALSE"
v.vmx["MemTrimRate"] = "0"
v.vmx["MemAllowAutoScaleDown"] = "FALSE"
v.vmx["mainMem.backing"] = "swap"
v.vmx["sched.mem.pshare.enable"] = "FALSE"
v.vmx["snapshot.disabled"] = "TRUE"
v.vmx["isolation.tools.unity.disable"] = "TRUE"
v.vmx["unity.allowCompostingInGuest"] = "FALSE"
v.vmx["unity.enableLaunchMenu"] = "FALSE"
v.vmx["unity.showBadges"] = "FALSE"
v.vmx["unity.showBorders"] = "FALSE"
v.vmx["unity.wasCapable"] = "FALSE"
end
nodes.each do |prefix, (count, ip_start)|
count.times do |i|
# Set the hostname
hostname = "%s" % [prefix, (i+1)]
# If we're using fusion, set some things here
config.vm.provider "vmware_fusion" do |v|
# Change up memory allocations as needed
v.vmx["memsize"] = 2048
end
# Build us some VMs
config.vm.define "#{hostname}" do |box|
# Everyone gets a hostname and networking, also an entry in /etc/hosts
box.vm.hostname = "#{hostname}.cook.book"
box.vm.network :private_network, ip: "172.16.80.#{ip_start+i}", :netmask => "255.255.255.0"
box.vm.network :private_network, ip: "10.10.80.#{ip_start+i}", :netmask => "255.255.0.0"
box.vm.synced_folder ".", "/vagrant", type: "nfs"
# The compute boxes get thown into chef with the single-compute role
if prefix == "rpcs-compute"
box.vm.provision :shell, :inline => "sudo echo '#{chefIP} chef.cook.book' >> /etc/hosts"
box.vm.provision :shell, :inline => "curl -L https://www.opscode.com/chef/install.sh | sudo bash"
box.vm.provision :shell, :path => "proxy.sh"
box.vm.provision :chef_client do |chef|
chef.chef_server_url = "https://chef.cook.book/"
chef.validation_key_path = "validation.pem"
chef.add_role "single-compute"
chef.environment = "havana"
# chef.delete_node = true
# chef.delete_client = true
end
# The controller, gets all-in-one. Because my laptop hates me otherwise.
elsif prefix == "rpcs-controller"
box.vm.provision :shell, :inline => "sudo echo '#{chefIP} chef.cook.book' >> /etc/hosts"
box.vm.provision :shell, :path => "#{prefix}.sh"
box.vm.provision :shell, :inline => "curl -L https://www.opscode.com/chef/install.sh | sudo bash"
box.vm.provision :chef_client do |chef|
chef.chef_server_url = "https://chef.cook.book/"
chef.validation_key_path = "validation.pem"
chef.environment = "havana"
chef.add_role "allinone"
# chef.add_recipe "tempest"
# chef.delete_node = true
# chef.delete_client = true
end
else
box.vm.provision :shell, :path => "#{prefix}.sh"
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment