Search code examples
vagrantvagrant-provision

Can you perform a vagrant provision from inside the VM?


Usually you have to run vagrant provision from outside your VM to create the VM to begin with. I then do a vagrant ssh to inspect the resultant VM.

If I wish to make small tweaks to the VM (using chef zero recipes in my case), I have to either switch to an other tab that is on my physical host, or exit the SSH session. it would be nice if you could do this run-and-inspect inside the previously created VM.

Why I'm asking: I have too many terminal tabs open for development and am looking for ways to prune, and avoid mental context switching (not to mention trying to figure out which tab is which).


Solution

  • No, you can not run a vagrant provision from inside the same vagrant machine. Vagrant is running on your host and provisioning the VM according to the specified vagrantfile. Any changes that you want to have applied during the provisioning must somehow come from the vagrantfile.

    What you can do is modify a running vagrant machine in any way you want from inside the vagrant machine, and then export the VM using vagrant package to a new vagrant box which then can be used as base for new vagrant VMs.

    PS: Not sure how you're dev environment looks like, but I suggest you look into terminal multiplexers like GNU screen or tmux, that might be able to help you with your "tab issues".