v0.4.0 updated website

This commit is contained in:
Mitchell Hashimoto 2010-06-10 14:23:39 -07:00
commit 76cfcd6774
12 changed files with 442 additions and 58 deletions

3
.gitignore vendored
View File

@ -5,4 +5,5 @@ pkg/*
.bundle/*
doc/
.yardoc/
Gemfile.lock
Gemfile.lock

View File

@ -34,3 +34,6 @@
</div>
<div id="content" class="container_12 clearfix">
<div class="grid_12 notice">
Vagrant 0.4 has been released! Read the <a href="/docs/changes/changes_03x_04x.html">full list of changes</a>.
</div>

View File

@ -13,7 +13,10 @@
</ul>
</li>
<li><a href="/docs/boxes.html">Boxes</a></li>
<li><a href="/docs/multivm.html">Multi-VM Environments</a></li>
<li><a href="/docs/host_only_networking.html">Host-Only Networking</a></li>
<li><a href="/docs/base_boxes.html">Base Boxes</a></li>
<li><a href="/docs/systems.html">Systems</a></li>
<li><a href="/docs/rake.html">Rake Integration</a></li>
</ol>
</div>
@ -23,4 +26,4 @@
<div class="grid_9 omega guide">
{{ content }}
</div>
{% include footer.html %}
{% include footer.html %}

View File

@ -209,22 +209,13 @@ you created by setting `config.ssh.private_key_path`.
### Setup the Vagrantfile
By default, Vagrant does not forward any ports. You probably want your base box
to automatically forward SSH, at the very least. This next step allows you to setup
a Vagrantfile which is packaged with your base box. Create this Vagrantfile in any
directory. The following shows the contents of a sample Vagrantfile which just
forwards SSH:
By default, Vagrant only forwards SSH (from port 22 to 2222 with automatic port
collision fixing enabled). If you want to modify any defaults or add any other
ports to forward, you will have to package a Vagrantfile with your box. You can
create a Vagrantfile in any directory.
{% highlight ruby %}
Vagrant::Config.run do |config|
# Forward the SSH port. The 'forward_port_key' should match the
# name of the forwarded port.
config.ssh.forwarded_port_key = "ssh"
config.vm.forward_port("ssh", 22, 2222)
end
{% endhighlight %}
This Vagrantfile will be used during the packaging phase of base box creation.
In the next section when the base box is packaged, it'll explain how to include
your custom Vagrantfile.
### Package and Distribute
@ -235,10 +226,12 @@ to the directory where your base box's Vagrantfile is, if you made one. If you
didn't make one, you can be in any directory.
Next, run `vagrant package`, specifying the name of the virtual machine in
VirtualBox that you want to package:
VirtualBox that you want to package. If you created a custom Vagrantfile, don't
forget to add `--include Vagrantfile` at the end of the following command as
well to include that in the package.
{% highlight bash %}
$ vagrant package --base my_base_box --include Vagrantfile
$ vagrant package --base my_base_box
{% endhighlight %}
This will take a few minutes, but the export will show you a progress bar. The

View File

@ -0,0 +1,96 @@
---
layout: documentation
title: Changes - 0.3.x to 0.4.x
---
# Changes in Vagrant 0.4.x
## VirtualBox 3.2 Support
Vagrant now supports VirtualBox 3.2.0 in addition to the 3.1.x series.
No configuration is necessary; Vagrant will automatically determine which
VirtualBox version is running and use the correct API calls.
## Multi-VM Environments
Vagrant can now automate and manage multiple VMs to represent a single
project. This allows developers to model more complex server setups on
their development machine. A very basic multi-VM Vagrantfile is shown
below:
{% highlight ruby %}
Vagrant::Config.run do |config|
config.vm.define :web do |web_config|
web_config.vm.box = "web"
web_config.vm.forward_port("http", 80, 8080)
end
config.vm.define :db do |db_config|
db_config.vm.box = "db"
db_config.vm.forward_port("db", 3306, 3306)
end
end
{% endhighlight %}
For more information, please read the page on [multi-VM environments](/docs/multivm.html).
## Host Only Networking
Prior to 0.4.x, Vagrant could only forward ports via a NAT connection.
Vagrant now allows VMs to specify a static IP for themselves, which
can be accessed on the host machine or any other VMs on the same
host only network. This feature can work hand in hand with the multi-VM
feature announced above to provide efficient internal networking between
VMs. An example of assigning a static IP to a VM is shown below:
{% highlight ruby %}
Vagrant::Config.run do |config|
config.vm.network("192.168.10.10")
end
{% endhighlight %}
For more information, read the page on [host only networking](/docs/host_only_networking.html).
## Automatic Port Collision Fixes
Since version 0.2.0, Vagrant has reported any potential port collisions
for forwarded ports. This was typically a rare occurence which only cropped
up when multiple Vagrant environments were running at the same time. With
the introduction of multi-VM support, port collision is now quite common.
To deal with this, Vagrant can now automatically resolve any port collisions
which are detected.
For an example and more information, please view the `config.vm.forward_port`
documentation on the [Vagrantfile page](/docs/vagrantfile.html#config-vm-forwardport).
## New Abstraction: Systems
"Systems" are a new abstraction within Vagrant which allow OS or system
specific behaviour such as shutdown or mounting folders to be defined within
a specific system class, which is then configured within the Vagrantfile.
Vagrant ships with a general Linux system which should cover the majority
of users and is the default system.
For more information, please read the [systems documentation](/docs/systems.html).
## Minor Changes
### `vagrant provision`
`vagrant provision` can now be called at any time to simply run the provisioning
scripts without having to reload the entire VM environment. There are certain
limitations to this command which are discussed further on the commands
documentation page.
### Relative Path Shared Folders
The host path for a shared folder can now be a relative path. This relative
path will be expanded relative to where the project Vagrantfile is. Example
below shows how the root shared folder is defined:
{% highlight ruby %}
config.vm.share_folder("v-root", "/vagrant", ".")
{% endhighlight %}
### Many Bug Fixes
As always, a handful of bugs have been fixed since Vagrant 0.3.0.

View File

@ -11,21 +11,41 @@ run `vagrant` alone:
{% highlight bash %}
$ vagrant
Usage: vagrant SUBCOMMAND ...
Usage: vagrant SUBCOMMAND
--help Show help for the current subcommand.
--version Output running Vagrant version.
Supported commands:
box Box commands
destroy Destroys the vagrant environment
halt Halts the currently running vagrant environment
init Initializes current folder for Vagrant usage
package Packages a vagrant environment for distribution
reload Reload the vagrant environment
resume Resumes a suspend vagrant environment
ssh SSH into the currently running environment
ssh-config outputs .ssh/config valid syntax for connecting to this environment via ssh
status Shows the status of the current environment.
suspend Suspends the currently running vagrant environment
up Creates the vagrant environment
Supported subcommands:
box Box commands
destroy Destroys the vagrant environment
halt Halts the currently running vagrant environment
init Initializes current folder for Vagrant usage
package Packages a vagrant environment for distribution
provision Run the provisioner
reload Reload the vagrant environment
resume Resumes a suspend vagrant environment
ssh SSH into the currently running environment
ssh-config outputs .ssh/config valid syntax for connecting to this environment via ssh
status Shows the status of the Vagrant environment.
suspend Suspends the currently running vagrant environment
up Creates the vagrant environment
For help on a specific subcommand, run `vagrant SUBCOMMAND --help`
{% endhighlight %}
## Built-in Help
You can quickly and easily get help for any given command by simply adding the
`--help` flag to any command. This will save you the trip of coming to
this documentation page most of the time. Example:
{% highlight bash %}
$ vagrant package --help
Description: Packages a vagrant environment for distribution
Usage: vagrant package [--base BASE] [--include FILES]
--help Show help for the current subcommand.
--base [BASE] Name or UUID of VM to create a base box from
--include x,y,z List of files to include in the package
{% endhighlight %}
<a name="vagrant-box"> </a>
@ -74,6 +94,17 @@ and register an identical virtual environment for other projects or other machin
that if you intend to recreate an identical experience for another developer using Vagrant that the Vagrantfile
residing at the root of your project directory should be included, see [Vagrant Boxes](/docs/boxes.html#creating-a-box) for more information.
<a name="vagrant-provision"> </a>
## vagrant provision
Runs the provisioning scripts without reloading the entire Vagrant environment.
If you're just tweaking or adding some cookbooks, this command can save you a
lot of time.
Since this command doesn't reload the entire environment or reboot the VM,
it will not add new cookbooks folders if the cookbooks folder path changes. In
this case, please call `vagrant reload`.
<a name="vagrant-resume"> </a>
## vagrant resume

View File

@ -38,7 +38,7 @@ multiple projects at the same time. Each project uses the box as a _base_ only,
project VM is created, modifications can be made without affecting other
projects which may use the same box.
Note that the box is given its own name, in this case "rails." This name
Note that the box is given its own name, in this case "getting_started." This name
is used throughout Vagrant to reference that box from this point forward.
The URL is only used when adding, but never again. And the filename of the
box means nothing to the logical name given. It is simply a coincidence that

View File

@ -0,0 +1,62 @@
---
layout: documentation
title: Documentation - Host-Only Networking
---
# Host-Only Networking
Host-Only networking is a feature of VirtualBox which allows multiple
virtual machines to communicate with each other through a network via
the host machine. The network created by host-only networking is private
to the VMs involved and the host machine. The outside world cannot
join this network.
Vagrant allows users to assign a static IP to a VM, which is then
setup using host-only networking.
<div class="info">
<h3>Debian/Ubuntu Only!</h3>
<p>
Since setting up host-only networking requires configuring the OS to
use the new interface, this is a system behavior. Currently, Vagrant
only supports Ubuntu/Debian out of the box.
</p>
<p>
If you'd like another OS supported, you can add it yourself using a
<a href="/docs/systems.html">custom system</a> or you can get in touch
with a Vagrant developer and assist us in adding it to the core.
</p>
</div>
## Assigning an IP
Assigning an IP to a virtual machine using Vagrant is simple enough,
using a single function within the Vagrantfile:
{% highlight ruby %}
Vagrant::Config.run do |config|
config.vm.network("192.168.10.10")
end
{% endhighlight %}
The above will setup the VM with that specific IP. It is up to the user
to make sure that no static IPs will collide with other virtual machines.
## Multiple Networks
By default, Vagrant uses a netmask of `255.255.255.0`. This means that
as long as the first three parts of the IP are equivalent, VMs will join
the same network. So if two VMs are created with IPs `192.168.10.10` and
`192.168.10.11`, they will be networked together. However, if a VM is
created with an IP of `192.168.11.10`, it will be on a separate network
and will not be able to communicate with the other VMs.
A custom netmask can also be used, although a netmask of `255.255.255.0`
should be sufficient in most cases. An example of using a custom netmask
is shown below:
{% highlight ruby %}
Vagrant::Config.run do |config|
config.vm.network("192.168.11.10", :netmask => "255.255.0.0")
end
{% endhighlight %}

112
docs/multivm.md Normal file
View File

@ -0,0 +1,112 @@
---
layout: documentation
title: Documentation - Multi-VM Environments
---
# Multi-VM Environments
Vagrant supports what are known as "Multi-VM Environments." These are Vagrant
environments which contain multiple virtual machines which typically work
together or are somehow associated with each other. An example of some uses of
Multi-VM environments:
* Accurately modeling a separate _web_ and _database_ server within the
same development environment.
* Running separate _web_ and _worker_ servers, for example a server which
handles media transcoding.
* Testing an interface, such as API calls or a chat interface.
* Testing a load balancer configuration, or the effects of "unplugging"
a machine.
Historically, running complex environments such as these was done by flattening
them onto a developer's machine. For example, in the case where there may typically
be a separate worker server which may process images, the web, queue, and workers
would all run side by side on the same development machine.
The problem with this is that it is an inaccurate model of the production setup.
Vagrant and Multi-VM environments allow developers to model complex multi-server
setups on a single development machine without getting in the way of the
development process (continue to use the same editors, tools, etc.).
## Defining Multiple VMs
The multiple VMs are all defined within the same single Vagrantfile which you're
probably already used to. A small example is shown below:
{% highlight ruby %}
Vagrant::Config.run do |config|
config.vm.define :web do |web_config|
web_config.vm.box = "web"
web_config.vm.forward_port("http", 80, 8080)
end
config.vm.define :db do |db_config|
db_config.vm.box = "db"
db_config.vm.forward_port("db", 3306, 3306)
end
end
{% endhighlight %}
Using `config.vm.define`, you can create multiple VMs (as many as you'd like) within
a single Vagrantfile. The `web_config` or `db_config` variables used within the
definitions are the exact same, functionally, as a Vagrantfile's typical `config`.
This allows the VMs to have their own custom configuration on any configurable
value.
In the case above, we're defining two VMs: "web" and "db." These two VMs are based
on two different boxes. The web VM forwards port 80 while the database VM forwards
port 3306.
## Controlling Multiple VMs
The moment that multiple VMs are introduced in a Vagrantfile, the usage of
the various `vagrant` command line commands change slightly. This change is hopefully
mostly intuitive, and will be shown using a very simple example based on `vagrant up`.
In a single VM environment, `vagrant up` starts that VM. In a multi-VM environment
`vagrant up` starts _every_ VM. If a name is specified to the command such as
`vagrant up web` then it will start only that specific VM.
This pattern follows for every other command as well, although some don't implement
the "every VM" functionality when it doesn't make sense, such as `vagrant ssh`, which
requires that a VM name be specified if its in a multi-VM environment.
## Communication Between VMs
With multiple VMs up and running, the next step is to support inter-VM
communication so that, say, a web server can talk to its associated database
server.
This communication is done through [host-only networking](/docs/host_only_networking.html). There is an entire page dedicated to the topic, but a relatively simple
example is given below, based on the example given earlier:
{% highlight ruby %}
Vagrant::Config.run do |config|
config.vm.define :web do |web_config|
# ...
web_config.vm.network("192.168.1.10")
end
config.vm.define :db do |db_config|
# ...
db_config.vm.network("192.168.1.11")
end
end
{% endhighlight ruby %}
The above assigns a static IP to both the web and database VMs. This
static IP can then be used to communicate directly to the other VMs.
For more details on how to do things such as creating separate networks,
joining the same network from separate Vagrantfiles, etc. please read
the [host-only networking](/docs/host_only_networking.html) page.
<div class="info">
<h3>All ports are open!</h3>
<p>
When assigning a static IP like the above, VirtualBox makes no attempt
to block any access to any port. Therefore, it is up to you to make sure
that the iptables or firewall are properly setup on each VM. This issue
does not pose a security threat, since the network is private to your machine,
but it is important to note for modeling production as accurately as possible.
</p>
</div>

View File

@ -66,18 +66,29 @@ around it:
task :up do
puts "About to run vagrant-up..."
env = Vagrant::Environment.load!
env.commands.up
env.commands.subcommand("up")
puts "Finished running vagrant-up"
end
{% endhighlight %}
The arguments to `subcommand` are simply an array of parameters
that you'd typically sent to the command line client, ignoring the `vagrant`
part. This allows you to do more complex things easily:
{% highlight ruby %}
desc "Package my environment with a custom file"
task :package do
env = Vagrant::Environment.load!
env.commands.subcommand("package", "--include", "MyCustomFile")
end
{% endhighlight %}
## SSH Commands
Perhaps you want to write a rake task that does some commands within the
virtual server setup? This can be done through the `ssh` accessor of the
environment, which is an instance of `Vagrant::SSH`. `Vagrant::SSH`
is simply a wrapper around `Net::SSH` and the objects returned are typically
`Net::SSH` objects.
virtual server setup? This can be done through the `ssh` accessor of any
VM within the environment, which is an instance of `Vagrant::SSH`. `Vagrant::SSH`
is simply a wrapper around `Net::SSH`.
The following example is a useful example showing how to create a graceful
shutdown command:
@ -86,11 +97,25 @@ shutdown command:
task :graceful_down do
env = Vagrant::Environment.load!
env.require_persisted_vm
env.ssh.execute do |ssh|
env.primary_vm.ssh.execute do |ssh|
ssh.exec!("sudo halt")
end
end
{% endhighlight %}
This example also shows `env.require_persisted_vm` which simply errors and
exits if there is no Vagrant VM created yet.
exits if there is no Vagrant VM created yet.
Additionally, if you're in a [multi-VM environment](/docs/multivm.html), you can
access the VMs through the `vms` array on the environment:
{% highlight ruby %}
task :graceful_down do
env = Vagrant::Environment.load!
env.vms.each do |vm|
vm.ssh.execute do |ssh|
ssh.exec!("sudo halt")
end
end
end
{% endhighlight %}

60
docs/systems.md Normal file
View File

@ -0,0 +1,60 @@
---
layout: documentation
title: Documentation - Systems
---
# Systems
Systems are an abstraction within Vagrant which describe how various operating system specific
tasks are to be run. Systems abstract away tasks such as shutting down, mounting folders, etc.
since some operating systems handle this slightly different. This opens the door to supporting
more than unix-like systems.
<div class="info">
<h3>This topic is for advanced users</h3>
<p>
The following topic is for <em>advanced</em> users. The majority of Vagrant users
will never have to do this. Therefore, only continue if you want to support a non-linux
based operating system.
</p>
</div>
## System Tasks
The following is a list of tasks which are delegated to system classes:
* **Halting** - Shutting down the machine gracefully
* **Mounting Shared Folders** - Creating, mounting, and setting up the permissions
for shared folders.
* **Enabling Host Only Networks** - Preparing and enabling host only networks on
specified interfaces.
This list will surely grow as Vagrant grows. For now, to implement a custom operating
system implementation, only the above two features need to be implemented.
## Creating a New System Implementer
Creating a new system implementer is quite simple: Inherit from `Vagrant::Systems::Base`
and implement the stubbed method on that class. Instead of going over each method here,
I'll point you to the [base source file](http://github.com/mitchellh/vagrant/blob/master/lib/vagrant/systems/base.rb)
which is thoroughly commented to explain each method. Its also recommended you view the
[linux system](http://github.com/mitchellh/vagrant/blob/master/lib/vagrant/systems/linux.rb)
which is currently the only system shipped with Vagrant.
## Using a New System Implementer
The new system implementer should be specified as the `config.vm.system` configuration
value. By default, this is `:linux`. A symbol represents a built-in system type. For
your custom types, you should set the value as the class name for your new implementer.
Below is a sample Vagrantfile which does just this:
{% highlight ruby %}
# An example system:
require 'bsd_system'
Vagrant::Config.run do |config|
# Set the system to the proper class name:
config.vm.system = BSDSystem
end
{% endhighlight %}
The configured Vagrant environment will then use the custom system implementation.

View File

@ -68,14 +68,6 @@ to use a custom SSH keypair.
`config.ssh.timeout` specifies the timeout when trying to connect to the virtual
environment.
### Deprecated SSH Configuration
These configuration keys will be completely removed in the next version of Vagrant.
They do nothing in the current version:
* `config.ssh.password` - Password SSH authentication has been completely
removed. This setting does nothing in the current version of Vagrant.
## config.vm
Vm settings are used when creating new virtual machines to alert Vagrant about how they
@ -116,9 +108,13 @@ config.vm.customize do |vm|
end
{% endhighlight %}
`config.vm.define` is a method which allows you to define a new VM for a multi-VM environment. Since
this is a huge topic in itself, please read its dedicated documentation page for more details.
`config.vm.disk_image_format` alerts Vagrant to the prefered virtual disk image file format for use when creating new virtual machines. VirtualBox
supports many disk formats such as .vdi (VirtualBox's own format), .vmdk (VMWare's disk image format), and .vhd (Microsoft's format).
<a name="config-vm-forwardport"> </a>
`config.vm.forward_port` is a function that will add a set of ports to forward from the host machine to the virtual machine
created with vagrant. The default Vagrantfile that is packaged with Vagrant itself forwards port 2222 on the host machine to
port 22 on the guest for ssh. Example usage of this is shown below:
@ -126,20 +122,21 @@ port 22 on the guest for ssh. Example usage of this is shown below:
{% highlight ruby %}
config.vm.forward_port("web", 80, 8080)
config.vm.forward_port("ftp", 21, 4567)
config.vm.forward_port("ssh", 22, 2222, :auto => true)
{% endhighlight %}
The first parameter of the `forward_port` method is simply a key used internally to reference the
forwarded port. It doesn't affect the actual ports forwarded at all. The above example could've
changed `web` to `fluffy bananas` and it still would've worked fine.
`config.vm.project_directory` tells Vagrant where to mount the current project directory as a shared folder
withing the new virtual machine's file system.
The final parameter is a hash of options which can be used to configure details of the forwarded
ports. `:adapter` allows you to specify which network adapter to forward the ports on. And if `:auto`
is set to true, then Vagrant will attempt to find a new port if it detects that the specified
port would collide with another VM.
{% highlight ruby %}
config.vm.project_directory = "/vagrant"
{% endhighlight %}
The above will use the vagrant folder under root as the mount point for the shared project directory.
`config.vm.network` is a method which allows a static IP to be assigned to a VM via
host only networking. This is a large enough topic that it has its own page. Please
read the page on host only networking for more information and details.
`config.vm.provisioner` tells Vagrant which provisioner to use to provision the system. By
default, this is set to `nil` which disables provisioning. It can also be set to a symbol
@ -158,10 +155,11 @@ guest machine, allowing the guest machine to read and write to a folder on the h
This function takes three parameters, in the same way as `config.vm.forward_port`, with the
first parameter being a key used internally to reference the folder, the second parameter being
the path on the guest machine, and the third parameter being the path to the folder to share
on the host machine.
on the host machine. If the third parameter is a _relative path_, then it is relative to where the root Vagrantfile is.
{% highlight ruby %}
config.vm.share_folder("my-folder", "/folder", "/path/to/real/folder")
config.vm.share_folder("another-folder", "/other", "../other")
{% endhighlight %}
## config.package
@ -248,4 +246,4 @@ config.chef.run_list = ["recipe[foo]", "recipe[bar]"]
# Using the helpers
config.chef.add_recipe("foo")
config.chef.add_role("bar")
{% endhighlight %}
{% endhighlight %}