Love Love - 6 months ago 19
Ruby Question

Modify my vagrantfile

I have a vagrantfile

Vagrant.configure(2) do |config|
config.vm.box = "puppetlabs/centos-7.0-64-puppet"
config.vm.network "private_network", ip: "172.28.128.4"
config.vm.network "public_network"
config.vm.provision :shell, path: "bootstrap.sh"
end


Now I have another code

config.vm.provider :virtualbox do |vb|
vb.gui = true
end


I want to combine them together. I heard that vagrant was written by
Ruby
. I am absolutely new to Ruby. So how do I do this?

Answer

In ruby you can nest blocks, so I think you just want this:

Vagrant.configure(2) do |config|
  config.vm.box = "puppetlabs/centos-7.0-64-puppet"
  config.vm.network "private_network", ip: "172.28.128.4"
  config.vm.network "public_network"
  config.vm.provision :shell, path: "bootstrap.sh"

  config.vm.provider :virtualbox do |vb|
    vb.gui = true
  end
end
Comments