Help! Vagrant keeps recreating my machine
We use Vagrant for development and sometimes on some OSX systems it decides that it must create a new virtual machine when there’s already one that is working perfectly! This is annoying as provisioning the new machine takes time. If you got here I assume you’re using VirtualBox like me.
Step 1: Please don’t reprovision
Setting a fixed name in your Vagrantfile will stop the creation of a new box immediately.
vb.name = “carwow_devbox”
Step 2: Don’t push a new SSH key
Pushing a new key will render your machine inaccessible without some fiddling. To stop it from happening just add this to your Vagrantfile.
config.ssh.insert_key = false
Step 3: Run this simple bash command
It will reconnect your previously working machine to the vagrant box. Substitute carwow_devbox with the name you chose in Step 1. Run this command in your terminal:
$ VBoxManage list vms | grep carwow_devbox | sed ‘s/”carwow_devbox” {\(.*\)}/\1/’ > ~/vagrant/.vagrant/machines/default/virtualbox/id
Step 4: Delete erroneously created box
Open VirtualBox and delete the newly created un–provisioned box.
Hope this article can help someone!
Interested in making an Impact? Join the carwow-team!
Feeling social? Connect with us on Twitter and LinkedIn :-)