I upgraded php to 5.6 within the Vagrant box 'trusty64', and also installed SOAP client. When I next update Vagrant I'm thinking it might overwrite these changes. Would I also need to change the provisioning in the vagrantfile, and if so what should I add?
When I next update Vagrant I'm thinking it might overwrite these
changes.
No, You would not loose anything if you upgrade vagrant. Once the VMs are created, vagrant will operate those VMs and upgrading vagrant will not impact the existing VM.
Basically, it works like this:
- when you run vagrant up, vagrant clone the box (which is VM files) and add the VM to VirtualBox
- after the VM have been created, vagrant "operates" (i.e. start, stop ...) the VirtualBox VM for you
Would I also need to change the provisioning in the vagrantfile
Thats necessary to change the provisioning if you plan to create more VM of this kind, or if you will destroy and recreate this VM; in this case the provisioning will run and you would need to have it updated.
and if so what should I add?
save all the commands you have run to run the upgrade and create a shell script out of it, might be the most simple option. You can also look at more advanced tool (puppet, ansible, chef .... that would do this job)
Related
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).
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".
I've started a VM on Google Compute Engine using Vagrant with the vagrant-google provider. I no longer wish to control the VM using Vagrant, but I would like it to keep running without me interrupting it.
What's the proper way to have Vagrant "forget" about this machine?
so the instance has been installed on GCE and you can control directly from there.
Locally you can delete the .vagrant folder that vagrant created in the folder when you launch it
After this to remove references you can run vagrant global-status --prune which will remove invalid entries and clean vagrant conf file from this machine
I am using nodejs with ansible and vagrant
I need to create a new machine for development with such things:
on every vagrant up I need to do:
run this script (to install all needed soft for development):
bash <(wget -qO- https://raw.githubusercontent.com/thoughtbot/laptop/master/linux)
NPM install on every submodule in my project
install and run mongodb service
How I can set these stuff to do automatically in vagrant or ansible?
You have a few options:
vagrant up, install your dependencies and repackage it as a box with: vagrant package or vagrant box repackage
Use chef/puppet/ansible provisioners, or even the shell provisioner. This will allow it to happen on vagrant up or vagrant provision
Roll your own in ruby and have vagrant run it (a vagrantfile is basically just ruby). I don't recommend this way.
I personally recommend 2 even though its the slowest (requires you to do all the owrk every time you destroy and up). 1 is a really good choice but I tend to keep vagrant as close to base state as possible so that no surprises pop up during deployment. And it makes it easier to share across people if you don't have to constantly re-package it and maintain that .box
Using Vagrant, is it possible to run my provisioning Ansible script just when vagrant up creates the virtual machine? I wan to provision just when the import sequence is run. I have a very slow step that imports the database. It isn't idempotent and I'd like it to run just the first time.
I can make a script using vagrant status and vagrant up --no-provision, but I believe there should be a more straightforward way.
I also can just run Ansible after the first vagrant up, but then I won't be able to brag to my friends that I create my server from scratch running just one command :-)
I think you are using a version older than 1.3.0;-)
Since Vagrant 1.3.0, vagrant up only run provisioning by default the first time it runs (after the import). Subsequent reload or up will need to explicitly specify the --provision flag, for example vagrant up --provision or just vagrant provision.
See the full changelog
The change => vagrant up will now only run provisioning by default the first time it is run. Subsequent reload or up will need to explicitly specify the --provision flag to provision. [GH-1776]
The question is basically in the title, but to expound a little: I've got a puppet manifest that runs on startup in our development Vagrant VMs. I'd like to add a couple things that make life easier for our developers -- things like bouncing Apache when our source files change or rebuilding our translation files when the master file is changed.
All of that seems simple enough to do, but I'm not sure whether it's possible to make the puppet service continue to monitor the machine after the VM is provisioned, and the Vagrant documentation doesn't seem to mention it.
Provisioning is a part of the vagrant up process, once the VM is up and running, it's finished.
NOTE: Provisioners in Vagrant allow you to automatically install software, alter configurations, and more on the machine as part of the vagrant up process.
I am NOT an expert on Puppet (Chef user), I think to bounce Apache if config files are changed, you may need an agent running on the VM.
BTW: vagrant provision can be used to run updated Chef cookbooks or Puppet modules after the VM is up.
Update
Since Vagrant 1.3.0 (released Sep 5, 2013)
vagrant up will now only run provisioning by default the first time it is run. Subsequent reload or up will need to explicitly specify the --provision flag to provision. [GH-1776]
See change log => https://github.com/mitchellh/vagrant/blob/master/CHANGELOG.md