Vagrant: Difference between revisions
Line 44: | Line 44: | ||
= Vagrantfile = | = Vagrantfile = | ||
Vagrantfile is just Ruby. | |||
== Vagrantfile template == | |||
If we run '''vagrant init''', we will get the following vagrantfile. | |||
<pre> | |||
VAGRANTFILE_API_VERSION = "2" | |||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |||
# ... | |||
end | |||
</pre> | |||
== Precise32 == | |||
<pre> | |||
VAGRANTFILE_API_VERSION = "2" | |||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |||
config.vm.box = "hashcorp/precise32" | |||
end | |||
</pre> | |||
== [https://docs.vagrantup.com/v2/vagrantfile/machine_settings.html config.vm] == | |||
'''Config namespace''': config.vm | |||
The settings within config.vm modify the configuration of the machine that Vagrant manages. | |||
* config.vm.boot_timeout | |||
* config.vm.box | |||
* config.vm.box_url | |||
* config.vm.communicator | |||
* config.vm.hostname | |||
* config.vm.provider | |||
* config.vm.synced_folder | |||
== [https://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html config.ssh] == | |||
= Boxes = | = Boxes = |
Revision as of 11:24, 1 January 2016
Official website https://www.vagrantup.com/
Resources
Documentation
https://docs.vagrantup.com/v2/
Books
- Vagrant Virtual Development Environment Cookbook (2015)
- Creating Development Environments with Vagrant (2015, 2nd Ed)
- Pro Vagrant (2015)
- Vagrant: Up and Running (2013)
Simple example
$ mkdir precise32 $ cd precise32 $ vagrant init hashcorp/precise32 A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. $ cat Vagrant VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "hashcorp/precise32" end $ vagrant up vm * The box 'hashcorp/precise32' could not be found.
The solution from stackoverflow works.
If we open VirtualBox GUI, we will see a new guest machine called precise32_default_XXXXXXXX is created and running though we do not see Ubuntu precise 32 desktop application in a new window.
Where is vagrant saving boxes files
http://stackoverflow.com/questions/10155708/where-does-vagrant-download-its-box-files-to
- Windows: C:/Users/USERNAME/.vagrant.d/boxes
- Linux and Mac: ~/.vagrant.d/boxes/
We can change the default directory by modifying the VAGRANT_HOME variable. See https://docs.vagrantup.com/v2/other/environmental-variables.html.
Vagrantfile
Vagrantfile is just Ruby.
Vagrantfile template
If we run vagrant init, we will get the following vagrantfile.
VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # ... end
Precise32
VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "hashcorp/precise32" end
config.vm
Config namespace: config.vm
The settings within config.vm modify the configuration of the machine that Vagrant manages.
- config.vm.boot_timeout
- config.vm.box
- config.vm.box_url
- config.vm.communicator
- config.vm.hostname
- config.vm.provider
- config.vm.synced_folder