OpenSearch/vagrant/Vagrantfile
Zachary Tong 19868a97bf Add Vagrant build environment (elastic/elasticsearch#38)
This adds a vagrant configuration under /vagrant. This allows the user to provision a virtual machine with the entire build environment needed for compiling the C++ portion of the code (as well as the Java side, but that can be done easily outside of vagrant).

Original commit: elastic/x-pack-elasticsearch@12754bd80e
2016-10-05 10:00:13 -04:00

30 lines
1.0 KiB
Ruby

Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |v|
host = RbConfig::CONFIG['host_os']
# Give VM 1/4 system memory
linux = RUBY_PLATFORM =~ /linux/
osx = RUBY_PLATFORM =~ /darwin/
windows = (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
if osx
cpus = `sysctl -n hw.ncpu`.to_i
mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024
end
if linux
cpus = `nproc`.to_i
mem = `sed -n -e '/^MemTotal/s/^[^0-9]*//p' /proc/meminfo`.to_i / 1024
end
if windows
cpus = `wmic computersystem get numberofprocessors`.split("\n")[2].to_i
mem = `wmic OS get TotalVisibleMemorySize`.split("\n")[2].to_i / 1024
end
mem = mem / 4
v.customize ["modifyvm", :id, "--memory", mem]
v.customize ["modifyvm", :id, "--cpus", cpus]
end
config.vm.provision :shell, path: "provision.sh"
config.vm.synced_folder "../", "/home/vagrant/prelert/src", mount_options: ["dmode=777,fmode=777"]
end