Run Ubuntu and Redhat on Mac OS

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

  1. Install Virtualbox from https://www.virtualbox.org/wiki/Downloads
  2. Install Vagrant https://www.vagrantup.com/
  3. Install plugin
    • vagrant plugin install vagrant-hostmanager
    • vagrant plugin install vagrant-disksize
  4. 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
  5. Start the VM: vagrant up u16 rh7
  6. SSH using vagrant command
    • vagrant ssh u16
    • vagrant ssh rh7
  7. 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

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer