In my ubuntu vagrant I've got a recipe that does apt-get update then apt-get upgrade -y. I've got a final recipe that reboots the machine if a restart is required. Since I'm using NFS to share my local directory, rebooting the VM makes the NFS share stop working. So then I need to issue a vagrant reload from my host.

Is it possible to issue something similar to vagrant reload from within the guest, or have some other way of reloading the vagrant NFS config once the VM has been rebooted? I don't want to have to write a script that runs on the host - I'm looking for a command I can drop into my reboot chef recipe so it'll reboot and reload the vagrant config.


The short answer will be "No", at least not without some really ugly workarounds and without breaking vagrant premise of running on every host system. You could for example ssh into your host from your virtual machine and execute a vagrant reload. There are also vagrant plugins, but I think they cannot take the return values from chef and act upon them. If they could, you could watch for specific statements and act accordingly.

I am also not sure you really want to upgrade your vm that way. Upgrading can break things in unexpected ways. I'd recommend taking the ubuntu base box from vagrantup, then upgrading manually and exporting this as a vagrant box you use. If you want to upgrade again, redo the process. It's a little more work but way safer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.