Commit Graph

247 Commits

Author SHA1 Message Date
Mitchell Hashimoto d64c164727 VM configuration only validates the active provider 2013-01-18 13:33:02 -08:00
Mitchell Hashimoto 003ebc811c VirtualBox uses the new validation middleware 2013-01-18 13:29:20 -08:00
Mitchell Hashimoto 7f55d5eac8 Builtin: ConfigValidate will validate your configuration 2013-01-18 13:26:14 -08:00
Mitchell Hashimoto fff021e51d Update Chef provisioner to new validation API 2013-01-18 13:12:02 -08:00
Mitchell Hashimoto df32c47780 Update puppet provisioner config to latest validation API 2013-01-18 13:08:38 -08:00
Mitchell Hashimoto 5e42a99ab6 Update shell provisioner to latest validation api 2013-01-18 13:06:29 -08:00
Mitchell Hashimoto 515ed8f119 Validate providers and provisioners! 2013-01-18 12:56:19 -08:00
Mitchell Hashimoto 3f3c7027aa Machine objects are passed into validate instead of env 2013-01-18 12:43:53 -08:00
Mitchell Hashimoto 3e9e422ce0 Convert existing validate methods to new API for kernel 2013-01-18 12:33:37 -08:00
Mitchell Hashimoto 10a051a64b box add works even if no provider is set 2013-01-16 22:52:44 -08:00
Mitchell Hashimoto c6c27c5e62 Catch Errno::ETIMEDOUT for SSH 2013-01-16 16:42:00 -08:00
Mitchell Hashimoto 129f1985bd Remove the "!" on chef client provision method. 2013-01-13 16:51:16 -08:00
Mitchell Hashimoto 0c8391aedd Chef uses the new provisioner API 2013-01-13 16:41:32 -08:00
Mitchell Hashimoto 51a227ae7e Puppet uses the new provisioner API 2013-01-13 16:22:47 -08:00
Mitchell Hashimoto 5c9f27626c Provisioner built-in uses new API 2013-01-13 16:09:32 -08:00
Mitchell Hashimoto 84c45a854c Remove the ProvisionerCLeanup action from VirtualBox 2013-01-13 16:03:34 -08:00
Mitchell Hashimoto cf2cca3b7c Revamp the configuration internal state for defining provisioners 2013-01-13 16:02:48 -08:00
Mitchell Hashimoto c8053c00a4 New provisioner API. Shell provisioner adheres to it. 2013-01-13 15:48:52 -08:00
Mitchell Hashimoto f1f4f276a0 Set the virtualbox config scope 2013-01-13 12:38:51 -08:00
Mitchell Hashimoto 965427c540 Properly upgrade V1 hostonly/bridged networks to V2 config 2013-01-13 01:07:55 -08:00
Mitchell Hashimoto 212e634c3b Make Provision a built-in action.
This allows other providers to just use it.
2013-01-12 16:22:37 -08:00
Mitchell Hashimoto 22571bf05b Rescue the EHOSTDOWN error for SSH 2013-01-12 12:47:49 -08:00
Mitchell Hashimoto 124a2ee5d3 Add the --provider optional flag to `box add` 2013-01-11 21:24:57 -08:00
Mitchell Hashimoto 2d8a048946 Merge branch 'abstract-networks'
This introduces the new network configuration syntax for Vagrant 1.1
and forward.

== The Problem

With multiple providers, the concept of networking as it stands in Vagrant
1.0.x becomes really muddy. We have `config.vm.forward_port` and
`config.vm.network :hostonly` and `config.vm.network :bridged`. But what
if someone writes an AWS provider? What is a bridged network in AWS? It
just doesn't make sense.

Networking working out of the box with Vagrant is a core part of what
makes Vagrant "magic" to new users. It is a core part of what makes Vagrant
simple to use. One option to punt networking to provider-specific
configuration was considered, but I found the whole idea of networking
too core to Vagrant to simply punt.

Because of this, a whole new method of networking is introduced.

== The Solution

The solution is to have a high-level notion of networking for Vagrant
configuration. This should cover the most _common_ cases of networking, and
every provider should do their best to implement these high-level
abstractions, to ensure the "just works" nature of Vagrant.

In addition to this high-level networking, low-level networking options
should be exposed on the provider configuration. This allows users to do
advanced provider-specific networking configuration if they want, but aren't
required to.

== High-Level Abstractions

=== Available Types

The high-level abstractions built into Vagrant will be the following:

* Forwarded ports - A mapping of host port to guest port that one can hit
  using `localhost`.
* Private network - A private network, the machine should ideally be
  protected from public access.
* Public network - A public network, one that is easily accessible by
  others.

I'm not sure if these are the proper abstractions. They can change up
until 2.0, but these are what we have so far.

Theoretically, here is how mappings would work. Note that this is just
an example, and the mappings in practice of such providers may or
may not map to this as follows.

**VirtualBox**
* Forwarded ports - NAT network, forwared ports.
* Private network - Hostonly network, static IP assigned.
* Public network - Bridged network, IP assigned via DHCP from router.

**VMWare**
* Forwarded ports - NAT network, forwarded ports.
* Private network - Hostonly network, static IP assigned.
* Public network - Bridged network, IP assigned via DHCP from router.

**AWS**
* Forwarded ports - Unimplemented.
* Private network - Public DNS in EC2, private IP in VPC.
* Public network - Elastic IP in EC2 and VPC.

=== Syntax

Networks are configured at the top-level of a Vagrantfile:

```ruby
Vagrant.configure("2") do |config|
  # ...

  config.vm.network :forwarded_port, 80, 8080
  config.vm.network :private_network, "192.168.1.12"
  config.vm.network :public_network
end
```

Providers should do their best to honor these configurations.

=== Advanced Options

While providers should do their best to satisfy the requirements for the
high-level abstractions, it is expected that provider-specific configuration
may be possible per network, even for the high-level configurations. For
this, provider-prefixed configuration options should be done:

```ruby
config.vm.network :forwarded_port, 80, 8000,
  :vmware__device => "vmnet8"

config.vm.network :public_network,
  :aws__elastic_ip => "1.2.3.4",
  :vmware__device => "en0"
```

If at all possible, providers should **not** require advanced options for
these to function.

== Low-level Configuration

While the high-level configuration should satisfy the common case and make
Vagrant work out of the box for most providers, one of the large benefits of
many providers is the ability to do certain networking tricks. For example,
KVM, Hyper-V, vSphere, etc. can create and be a part of true VLANs, which
may be required for certain upstream networking rules/ACLs. For things like
this, the network configuration should go directly into the provider
configuration in some way.

Examples:

```ruby
config.vm.provider :virtualbox do |vb|
  vb.network_adapter 2, :hostonly
  vb.network_adapter 3, :nat
end

config.vm.provider :aws do |aws|
  aws.routing_table = "route-123456"
end
```

It is up to the provider implementation to define the configuration
syntax as well as the implementation details of such an option. Other
providers are unable to see provider configurations other than their own
so it is truly private to the provider.
2013-01-11 16:18:09 -08:00
Mitchell Hashimoto 48eaa93745 Raise proper error if there aren't any NIC slots available 2013-01-11 15:57:08 -08:00
Mitchell Hashimoto 7cd663391e Forwarded ports allow for scoped hash overrides 2013-01-11 15:52:45 -08:00
Mitchell Hashimoto 102e8f23d6 Use scoped hash overrides for high-level config 2013-01-11 15:50:09 -08:00
Mitchell Hashimoto ccc4da0d32 Remove the old networking code 2013-01-11 15:23:20 -08:00
Mitchell Hashimoto 48995f6036 Support mac address and nic_type for host only networks 2013-01-11 15:22:55 -08:00
Mitchell Hashimoto d09dc91d1b Add support for bridged networks again 2013-01-11 15:21:09 -08:00
Mitchell Hashimoto 37e158c9b2 Configure networks on the VM 2013-01-11 15:06:38 -08:00
Mitchell Hashimoto da7f227fff Forwarded ports use the new high-level configuration 2013-01-11 14:51:49 -08:00
Mitchell Hashimoto 7e5f175d2c Check port collisions now uses the new high-level networking 2013-01-11 14:44:27 -08:00
Mitchell Hashimoto 2d8f9baf7f New Network VirtualBox middleware to handle the changes.
Note this is a WIP (hence committed on a branch)
2013-01-11 14:16:00 -08:00
Mitchell Hashimoto 8299ac38bd Rework v1 forward_port call to append forward port networks 2013-01-10 12:06:08 -08:00
Mitchell Hashimoto 09126b20d3 Merge pull request #1283 from eladroz/master
Fixing guest code for RH & SUSE
2013-01-06 17:38:09 -08:00
Jordi Llonch 793ad58e96 fedora 17 & 18 support 2013-01-07 05:23:07 +11:00
Mitchell Hashimoto 7a9363e8a1 Fix ordering of forwarded_port call 2013-01-04 16:35:13 -10:00
Mitchell Hashimoto 559cf25b5f Temporarily disable Network action while it is broken 2013-01-04 16:25:20 -10:00
Mitchell Hashimoto 2d3c0b7148 VirtualBox forwarding port uses new `network` calls 2013-01-04 16:22:38 -10:00
Mitchell Hashimoto a2cf0270a3 Remove network validation on config. We'll re-add this later. 2013-01-04 16:13:02 -10:00
Mitchell Hashimoto 640b296f5a Explicitly set error handling for port collision on resume 2013-01-04 16:11:40 -10:00
Mitchell Hashimoto be36c702d6 Booting new VirtualBox VM should check for port collisions 2013-01-04 16:08:37 -10:00
Mitchell Hashimoto 5c950d8200 Remove old `forward_port` method for configuration. Use `network` 2013-01-04 15:48:54 -10:00
Mitchell Hashimoto a4896293ff Merge pull request #1260 from hdorio/master
Attempt to fix #1108, #1109, tcp and udp port on the same port number
2013-01-03 17:13:07 -08:00
Elad Rosenheim 0915186b26 Fix guest plugin for RH & SUSE 2012-12-31 10:38:36 +02:00
Mitchell Hashimoto cd969e1e05 Remove the dotfile_name configuration option.
The dotfile is gone now so the configuration option is obselete
2012-12-26 21:45:24 -08:00
Mitchell Hashimoto d54d58c09c Call `finalize!` properly on provider configurations 2012-12-26 21:44:43 -08:00
Mitchell Hashimoto e955596939 Set a default for the "gui" option for VirtualBox 2012-12-25 09:18:47 -08:00
Mitchell Hashimoto 54a2f6b89e Change boot_mode to a provider config `gui`.
OLD:

config.vm.boot_mode = :gui

NEW:

config.vm.provider :virtualbox do |vb|
  vb.gui = true
end
2012-12-25 09:00:06 -08:00
Mitchell Hashimoto 2cfc5986d2 Wording changes in the status command. VM => machine 2012-12-24 10:00:28 -08:00
Mitchell Hashimoto 8fe0f86dbd The --provider flag for `up` now actually does something. 2012-12-23 21:23:08 -08:00
Mitchell Hashimoto 8cc4910fa9 Merge commit that got missed. Ignore changes in this comit. Read message
This branch brings in a whole lot of awesome. The name does not do it
justice. The list of things that comes into play here:

* "virtualbox" is no longer hardcoded anywhere in core. It is the default
  provider, yes, but it is 100% possible now to slip in another provider
  and have it work.

* `vagrant up --provider` is a thing. This allows you to specify an
  alternate provider. Note that the other commands don't support
  `--provider` yet so its not THAT useful, but its getting really close.

* True V2 configuration is in place. That means that `Vagrant.configure`
  calls now are loading a completely new configuration version, and old
  1.0.x Vagrantfiles are V1 configuration. V1 configuration is upgraded
  automatically internally, so backwards compatibility is maintained.
  Magic, people, magic.

* `config.vm.provider` is the major new configuration option. This is
  how provider-specific configuration will be done. For example, Vagrant
  has always provided a way to make a pass of `VBoxManage` calls to
  customize your VM via `config.vm.customize` in V1. This now exists
  as a VirtualBox configuration option. See the example here:
  https://gist.github.com/98f5a0df6a05286dfb73

* Unit tests no longer depend on VirtualBox being installed, because for
  unit tests we slip in a "no-op" provider, which is a fully valid
  Vagrant provider plug-in that does... NOTHING! Brilliant!

* Lots of core middleware executor improvements that make writing and
  using middleware stacks a lot more enjoyable. Enjoy a set of "standard
  library middlewares" provided by Vagrant in Vagrant::Action::Builtin.

The multi-provider is really shaping up here.
2012-12-23 16:34:09 -08:00
Mitchell Hashimoto 178c47992c Remove unused files 2012-12-23 16:29:26 -08:00
Mitchell Hashimoto a671fdcbcb Upgrade sub-VM defines from old config 2012-12-23 16:29:26 -08:00
Mitchell Hashimoto 3808ea377f Upgrade all other default configurations to V2 2012-12-23 16:29:26 -08:00
Mitchell Hashimoto bf53abca76 VM config upgrades provisioners 2012-12-23 16:29:25 -08:00
Mitchell Hashimoto ed6123ac77 Upgrade all VM configs except provisioners (TODO still) 2012-12-23 16:29:25 -08:00
Mitchell Hashimoto 9f6b091575 Comment clarification 2012-12-23 16:29:25 -08:00
Mitchell Hashimoto 9f893534f1 Upgrade VM customizations 2012-12-23 16:29:25 -08:00
Mitchell Hashimoto e88d735cb6 Make configured VM providers default to an empty one 2012-12-23 16:29:25 -08:00
Mitchell Hashimoto 553d4a828a Make sure provider config is always available even if no block was given 2012-12-23 16:29:25 -08:00
Mitchell Hashimoto 6478139cee Move config.vm.customize to VirtualBox specific option 2012-12-23 16:29:25 -08:00
Mitchell Hashimoto 66849fda20 When recovering on import and destroying, force it 2012-12-23 16:29:25 -08:00
Mitchell Hashimoto 1ee470a551 Begin work on supporting provider-specific configuration
This works by registering a `config` with `:provider => true` with the
same name as your provider. Vagrant will then automatically configure
the provider when `config.vm.provider` is used.
2012-12-23 16:29:24 -08:00
Mitchell Hashimoto 666f9f802d When upgrading V1 `vm` config, don't set on new if it wasn't set before 2012-12-23 16:29:24 -08:00
Mitchell Hashimoto b6c6614fd8 Basic upgrade support for the `vm` config settings. VERY basic. 2012-12-23 16:29:24 -08:00
Mitchell Hashimoto 5adcb0fc43 Merge pull request #1232 from paulmars/master
Altered messages so they were _not_ self referencing.
2012-12-21 12:15:02 -08:00
Mitchell Hashimoto b9f6afd2a0 Scrub LD_LIBRARY_PATH prior to executing VBoxManage 2012-12-16 10:37:43 -08:00
Hadrien Dorio 76c9f671f3 fixes tcp and udp on the same port number GH-1108, GH-1109
fix a bug in forward_port_definitions() in Action::ForwardPorts
2012-12-13 20:03:45 +01:00
Mitchell Hashimoto 42f157143f Forward-port fix for OS X and VirtualBox bug from 1-0-stable 2012-11-20 11:00:19 -08:00
Paul McKellar 2b0c4e6385 Change description of plugins to avoid self referencial definitions. e.g. 'destroy' will destroy your VM 2012-11-19 13:10:04 -08:00
Mitchell Hashimoto 67855be77b Add the Environment#machine method
This will eventually replace the Environment#vms method. Because of the
introduction of providers, the environment doesn't know what the backing
of the machines will be (and they're _machines_ now, not _vms_).
Instead, users of Environment will now call `#machine` on the
environment to retrieve a machine with the given backing provider as it
needs it.
2012-11-07 21:45:09 -08:00
Mitchell Hashimoto 83e99bbe4e config.vm.provider (although it doesn't do anything yet) 2012-11-07 20:38:41 -08:00
Mitchell Hashimoto d254d6f718 Configure the V2 kernel. 2012-11-06 21:28:44 -08:00
Mitchell Hashimoto 2de124e296 Turn provisioners to V2 2012-11-06 21:21:36 -08:00
Mitchell Hashimoto 81ca275792 Providers to V2 2012-11-06 21:20:55 -08:00
Mitchell Hashimoto 5a33b7ee54 Hosts to V2 2012-11-06 21:20:22 -08:00
Mitchell Hashimoto 1d2beff649 Guests to V2 2012-11-06 21:14:45 -08:00
Mitchell Hashimoto 45f211b19e Communicators to v2 plugins. 2012-11-06 21:14:10 -08:00
Mitchell Hashimoto e8370f0098 Convert comands to V2 plugins. 2012-11-06 21:09:29 -08:00
Mitchell Hashimoto 399437e758 Mark core config classes as upgrade safe 2012-11-03 21:41:04 -07:00
Mitchell Hashimoto 6df6f6764f Remove plugin activation. It really isn't necessary.
It was only used in a couple places and it isn't necessary since you can
do the loading within the actual blocks themselves.
2012-11-03 20:29:34 -07:00
Mitchell Hashimoto 335d9fad1f Merge pull request #1191 from lorello/master
Fix change_host_name on Ubuntu Hardy
2012-11-02 21:32:59 -07:00
Mitchell Hashimoto f72054b195 Merge pull request #1209 from pbrisbin/arch-fix-3
Additional Arch host class fixes
2012-11-02 21:29:44 -07:00
Dan Carley fec9410814 Omit empty lines in Puppet provisioner output
The sudo() block and/or the Puppet provisioner often returns newline
characters as separate strings. This makes the chomp() ineffective and
results in extraneous spacing between the output lines.

Separate out the call to chomp() so that we only do it once. Then only
output info if that line is not an empty string.
2012-10-30 11:24:10 +00:00
Mitchell Hashimoto 44804ce94b Fix old channel usage on chef client provisioner 2012-10-26 16:39:51 -07:00
patrick brisbin 8c7c345bc0 Use a better check for systemd
Using `which systemctl` would return true on even non-systemd machines
during this transitional time.
2012-10-26 14:16:04 -04:00
patrick brisbin 6905513481 Fix match? and nfs? for Arch host 2012-10-26 14:15:58 -04:00
Mitchell Hashimoto 625741ab6a Allow hostnames to be subset of box name for Ubuntu 2012-10-12 20:06:54 -07:00
Mitchell Hashimoto 3c0341b7be Disable DNS proxy for 12.10 too 2012-10-12 20:03:25 -07:00
Mitchell Hashimoto 5b4a132fdd Merge pull request #1176 from paulv/master
Fix for DNS resolution bug on Ubuntu 12.10
2012-10-12 20:01:37 -07:00
Mitchell Hashimoto 3d0c82edad Merge pull request #1175 from petere/puppet-exitcodes
Check exit codes of puppet provisioners
2012-10-12 19:56:19 -07:00
Mitchell Hashimoto 544006c16c Whitespace and such 2012-10-12 19:51:25 -07:00
LoreLLo fc0a0d04e5 fix change_host_name for Ubuntu Hardy 2012-10-12 18:11:52 +02:00
Richard Bullington-McGuire cced762645 Fix Windows shell provisioning
Resolves [GH-1036] [GH-1164] [GH-1181]

Ported fixes from patches to 1-0-stable
2012-10-11 20:33:37 -04:00
Paul Visscher f36ab8a165 Fixes a bug with DNS resolution in Ubuntu 12.10. 2012-10-08 22:12:41 -04:00
Peter Eisentraut 901d3ad23b Check exit codes of puppet provisioners
Previously, failures in applying the puppet manifests would be
ignored, because puppet apply/agent don't have any useful exit codes
by default.  (Errors are printed, but vagrant continues.)

Use the option --detailed-exitcodes of puppet apply/agent to check for
success.
2012-10-08 15:22:30 -04:00
Mitchell Hashimoto c1e99713bd Merge pull request #1146 from piavlo/master
make chef provisioners to write human readable dna.json
2012-09-27 14:01:47 -07:00
Mitchell Hashimoto 88277fa2e0 Merge pull request #1067 from jtimberman/chef-command-args
Add config.arguments for Chef
2012-09-27 13:53:29 -07:00