DEV Community

Cover image for Run Vagrant VMs in a M1/M2/M3 Apple Sillicon Chip
Houssam Bourkane
Houssam Bourkane

Posted on

Run Vagrant VMs in a M1/M2/M3 Apple Sillicon Chip

If you're a Mac user equipped with an Apple Silicon chip (M1/M2/M3...) and facing challenges setting up a Vagrant infrastructure due to the lack of supported hypervisors, this tutorial is tailored for you. It will guide you through configuring Vagrant to run using VMware Fusion technology as a hypervisor. Simply follow the steps outlined, and should you encounter any issues along the way, feel free to reach out to me for assistance.

Step 1: Install Rosetta

/usr/sbin/softwareupdate --install-rosetta --agree-to-license 
Enter fullscreen mode Exit fullscreen mode

Step 2: Install VMware Fusion tech (you will have to create a VMware account)

https://customerconnect.vmware.com/downloads/get-download?downloadGroup=FUS-TP2023 
Enter fullscreen mode Exit fullscreen mode

You may also need to provide a license key, you can opt for the free one.

Step 3: Create a symbolic link

ln -s /Applications/VMWare\ Fusion\ Tech\ Preview.app /Applications/VMWare\ Fusion.app 
Enter fullscreen mode Exit fullscreen mode

Step 4: Install vagrant (on MacOS)

brew tap hashicorp/tap brew install hashicorp/tap/hashicorp-vagrant 
Enter fullscreen mode Exit fullscreen mode

Step 5: Install vagrant vmware utility

https://releases.hashicorp.com/vagrant-vmware-utility/1.0.22/vagrant-vmware-utility_1.0.22_darwin_amd64.dmg 
Enter fullscreen mode Exit fullscreen mode

Step 6: Install vagrant plugin

vagrant plugin install vagrant-vmware-desktop 
Enter fullscreen mode Exit fullscreen mode

Step 7: Create a Vagrantfile

This configuration will create 2 VMs (master and slave)

mkdir vagrant-project cd vagrant-project touch Vagrantfile cat << EOF > Vagrantfile Vagrant.configure("2") do |config| config.vm.define "master" do |master| master.vm.box = "spox/ubuntu-arm" master.vm.box_version = "1.0.0" master.vm.hostname = 'master' master.vm.provision "docker" master.vm.network :private_network, ip: "192.168.56.101" master.vm.provider "vmware_desktop" do |v| v.allowlist_verified = true v.gui = false v.vmx["memsize"] = "2048" v.vmx["numvcpus"] = "2" end end config.vm.define "slave" do |slave| slave.vm.box = "spox/ubuntu-arm" slave.vm.box_version = "1.0.0" slave.vm.hostname = 'slave' slave.vm.provision "docker" slave.vm.network :private_network, ip: "192.168.56.102" slave.vm.provider "vmware_desktop" do |v| v.allowlist_verified = true v.gui = false v.vmx["memsize"] = "2048" v.vmx["numvcpus"] = "2" end end end EOF 
Enter fullscreen mode Exit fullscreen mode

Note: gui parameter is mandatory

Step 8: Now you can run the vagrant program

vagrant up 
Enter fullscreen mode Exit fullscreen mode

Additional commands

Check the status of the VMs
vagrant status 
Enter fullscreen mode Exit fullscreen mode
Connect to the VMs
vagrant ssh <hostname> 
Enter fullscreen mode Exit fullscreen mode

In our example we can use either

vagrant ssh master 
Enter fullscreen mode Exit fullscreen mode

Or

vagrant ssh slave 
Enter fullscreen mode Exit fullscreen mode
Stop the VMs
vagrant halt 
Enter fullscreen mode Exit fullscreen mode
Delete the VMs
vagrant destroy 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)