Vagrant
-
Upload
denys-haryachyy -
Category
Software
-
view
1.912 -
download
3
Transcript of Vagrant
![Page 1: Vagrant](https://reader036.fdocuments.net/reader036/viewer/2022092623/58738b2b1a28ab272d8b6a29/html5/thumbnails/1.jpg)
VagrantVirtualbox provider guide
![Page 2: Vagrant](https://reader036.fdocuments.net/reader036/viewer/2022092623/58738b2b1a28ab272d8b6a29/html5/thumbnails/2.jpg)
InstallPrerequisites
apt-get -y install virtualbox virtualbox-dkms vagrant
VM image
vagrant box add trusty64 https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vbox.box
![Page 3: Vagrant](https://reader036.fdocuments.net/reader036/viewer/2022092623/58738b2b1a28ab272d8b6a29/html5/thumbnails/3.jpg)
OperateStart image
vagrant init && vagrant up
Connect
vagrant ssh
Suspend or shutdown
vagrant suspend && vagrant halt
![Page 4: Vagrant](https://reader036.fdocuments.net/reader036/viewer/2022092623/58738b2b1a28ab272d8b6a29/html5/thumbnails/4.jpg)
ProvisioningCreate bootstrap.sh with all the configuration
Modify Vagrantfile
config.vm.provision :shell, path: "bootstrap.sh"
Provision
vagrant provision
![Page 5: Vagrant](https://reader036.fdocuments.net/reader036/viewer/2022092623/58738b2b1a28ab272d8b6a29/html5/thumbnails/5.jpg)
Bootstrap as a regular userBy default script is run as root, to run as a different user do the following.case $(id -u) in
0) # doing root tasks
sudo -u vagrant -i $0
;;
*) # doing user tasks
;;
esac
![Page 6: Vagrant](https://reader036.fdocuments.net/reader036/viewer/2022092623/58738b2b1a28ab272d8b6a29/html5/thumbnails/6.jpg)
Configure CPU and RAMModify Vagrantfile
config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
vb.customize ["modifyvm", :id, "--ioapic", "on"]
vb.customize ["modifyvm", :id, "--cpus", "4"]end
![Page 7: Vagrant](https://reader036.fdocuments.net/reader036/viewer/2022092623/58738b2b1a28ab272d8b6a29/html5/thumbnails/7.jpg)
Configure networkModify Vagrantfile
config.vm.network "public_network", bridge: "br-1", ip: "192.168.56.2"
config.vm.network "public_network", bridge: "br-2", ip: "192.168.57.2"
config.vm.network "public_network", bridge: "br-3", ip: "192.168.58.2"
![Page 8: Vagrant](https://reader036.fdocuments.net/reader036/viewer/2022092623/58738b2b1a28ab272d8b6a29/html5/thumbnails/8.jpg)
Copy files to VMVagrant.configure("2") do |config| # ... other configuration
config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"end
![Page 9: Vagrant](https://reader036.fdocuments.net/reader036/viewer/2022092623/58738b2b1a28ab272d8b6a29/html5/thumbnails/9.jpg)
GUIconfig.vm.provider "virtualbox" do |vb| vb.gui = trueend
![Page 10: Vagrant](https://reader036.fdocuments.net/reader036/viewer/2022092623/58738b2b1a28ab272d8b6a29/html5/thumbnails/10.jpg)
ReferencesVagrant virtualbox configuration
How to make Vagrant performance not suck