I'm new to vagrant, I'm using scotchbox.
I've configured a couple of vhosts in apache.
I guess the right way to do this would have been to change the provisionning of my box (as it's the aim of vaghrant right?) but i did the old school way by simpply editing my config files and so on...
Now my question is :
if i run vagrant destroy, do i loose all my configs?
is there any other command (vagrant halt, vagrant suspend?) that would allow me to reboot my host machine without loosing my config?
vagrant destroy will remove entire VM so any changes that were made manually will be lost. Vagrant halt only turns of the power so to speak so nothing is lost. If you run your machine again or reboot it all your data is save, just don't use --provision option that will recreate all initial configuration.
Related
Is it possible to configure the Vagrantfile, so vagrant box update run automatically when the box is starting via vagrant up?
No, it's not possible, as you can see in the Vagrant docs:
Using the Vagrantfile, you can also configure Vagrant to automatically check for updates during any vagrant up. This is enabled by default, but can easily be disabled with config.vm.box_check_update = false in your Vagrantfile.
When this is enabled, Vagrant will check for updates on every vagrant up, not just when the machine is being created from scratch, but also when it is resuming, starting after being halted, etc.
If an update is found, Vagrant will output a warning to the user letting them know an update is available. That user can choose to ignore the warning for now, or can update the box by running vagrant box update.
Vagrant can not and does not automatically download the updated box and update the machine because boxes can be relatively large and updating the machine requires destroying it and recreating it, which can cause important data to be lost. Therefore, this process is manual to the extent that the user has to manually enter a command to do it.
You can check more of the docs in this link
Hadoop & Vagrant: If I set up a new VM using these two packages, is the VM available for starting with VirtualBox or do I always have to use vagrant up?
When you first create the VM, you will need to use vagrant up since VirtualBox has no ability to read a Vagrantfile. Once your VM is up and running, you could stop and start it using VirtualBox. However, Vagrant can perform the same operations as VirtualBox and has a lot of advantages on top of that.
First let's discuss how Vagrant can do what VirtualBox can do. You can use vagrant suspend to put the VM in a saved state, vagrant resume to start it again, vagrant halt to power it off, and vagrant destroy to delete it. You can also use settings in Vagrant's VirtualBox provider to modify your VM's memory, CPUs, and more. You can also change the network settings and synced folders. And this gives you the advantage of defining all of these settings in code which can be checked into a revision control system such as Git.
On top of all this, Vagrant has support for provisioners. These range from something as simple as shell scripts to full blown configuration management tools such as Puppet, Chef, Ansible, and Salt. Just like you can define your VM's VirtualBox settings in code, you can define the entire creation process including installing packages, managing services, and customizing files. And you can make changes at any time and apply them using vagrant provision.
So getting back to your question... yes, you can control your VM directly with VirtualBox, but you'd be missing out on the rich feature set of Vagrant.
When I create a new Laravel 5 project, I edit my Homestead.yaml, my /etc/hosts and then do:
homestead halt
homestead up --provision
That makes my new site available but I lose my database tables for ALL of my other projects on the machine and have to manually reload them from backups. I've searched around and it sounds like this is a known issue but I want to clarify that I'm not doing something stupid (which is likely).
I think you should try to use vagrant command instead.
When you have your homestead machine running, try running vagrant provision in the directory where you have your Vagrantfile. It should reload the machine and your sites should be visible and any data shouldn't be removed in this case.
If you do not want to lose existing data do as follows:
vagrant reload --provision
Trust me when i say that I tried all the advice and almost every time all my databases were destroyed.
For a proper provisioning in Homestead machine, use global-status command of Vagrant to find out your Homestead's machine ID. This provides a result as the following image.
Then run vagrant provision {your-machine-id}.
I'm problem with my Vagrant boxes. I had a number of boxes in operation, opened my Vagrantfile to add a new box config. Then when I ran vagrant up new_box, I was told that it could not boot and was subsequently placed in poweroff state. Now ALL my boxes are in poweroff state when I check vagrant status. The apps running on these boxes are still running though, but I can't ssh into them. I also cannot run vagrant halt, nothing seems to happen. When I run vagrant up port collisions occur.
In short, my Vagrant boxes are running (sort of), but they aren't really?
EDIT
I have tried destroying a box (rather than just halting) and then running vagrant up again, but the port is still occupied when I try to bring the box back up again... However, when I check netstat the host ports are not listed as in use by any application.
The problem was caused by an update of VirtualBox performed by the server admin (without me knowing). Also, a kernel update was being performed.
I like how through vagrant I can spin up my machine, configure it and get to coding. However when I do vagrant halt, and then do a vagrant up again, it rebuilds my machine from the base box. All the new stuff I installed, my project repository is gone.
I can see that the virtual machine still exists in virtual box and I can use it from there, but I want to use vagrant to manage it and access it while keep the persistence of the disk as I would accessing it directly from virtual box. My host is windows, my guest is precise64.
Thoughts?
Stephen
Maybe you want to use vagrant suspend? (via)