Example
Create two virtual machines with following settings
OS | hostname | vCPU | Memory | Internal IP |
Ubuntu 16 | u16 | 2 | 2048 MB | 192.168.77.10 |
Redhat 7 | rh7 | 1 | 1024 MB | 192.168.77.11 |
Steps
- Install Virtualbox from https://www.virtualbox.org/wiki/Downloads
- Install Vagrant https://www.vagrantup.com/
- Install plugin
- vagrant plugin install vagrant-hostmanager
- vagrant plugin install vagrant-disksize
- Create a vagrant file
Vagrant.configure("2") do |config| config.hostmanager.enabled = true config.hostmanager.manage_host = true config.hostmanager.manage_guest = true config.disksize.size = "20GB" config.vm.define "u16" do |node| node.vm.hostname = "u16" node.vm.box = "generic/ubuntu1604" node.vm.network "private_network", ip:"192.168.77.10" node.vm.provider :virtualbox do |vb| vb.customize ["modifyvm", :id, "--memory", "2048"] vb.customize ["modifyvm", :id, "--cpus", "2"] end end config.vm.define "rh7" do |node| node.vm.hostname = "rh17" node.vm.box = "generic/rhel7" node.vm.network "private_network", ip:"192.168.77.11" node.vm.provider :virtualbox do |vb| vb.customize ["modifyvm", :id, "--memory", "1024"] vb.customize ["modifyvm", :id, "--cpus", "1"] end end end
- Start the VM: vagrant up u16 rh7
- SSH using vagrant command
- vagrant ssh u16
- vagrant ssh rh7
- SSH
- ssh -i .vagrant/machines/u16/virtualbox/private_key vagrant@u16
- ssh -i .vagrant/machines/rh7/virtualbox/private_key vagrant@rh7
References
- Search Vagrant Boxes
- https://app.vagrantup.com/boxes/search?provider=virtualbox