How do I increase the RAM and set up host-only networking in Vagrant?
To increase the memory or CPU count when using Vagrant 2, add this to your Vagrantfile
Vagrant.configure("2") do |config|
# usual vagrant config here
config.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
end
Since Vagrant 1.1
customize
option is getting VirtualBox-specific.
The modern way to do it is:
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "256"]
end
You can modify various VM properties by adding the following configuration (see the Vagrant docs for a bit more info):
# Configure VM Ram usage
config.vm.customize [
"modifyvm", :id,
"--name", "Test_Environment",
"--memory", "1024"
]
You can obtain the properties that you want to change from the documents for VirtualBox command-line options:
- http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm
The vagrant documentation has the section on how to change IP address:
Vagrant::Config.run do |config|
config.vm.network :hostonly, "192.168.50.4"
end
Also you can restructure the configuration like this, ending is do with end without nesting it. This is simpler.
config.vm.define :web do |web_config|
web_config.vm.box = "lucid32"
web_config.vm.forward_port 80, 8080
end
web_config.vm.provision :puppet do |puppet|
puppet.manifests_path = "manifests"
puppet.manifest_file = "lucid32.pp"
end