vagrant 0.8.10 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +77 -1
- data/Gemfile +0 -14
- data/LICENSE +1 -1
- data/bin/vagrant +47 -20
- data/config/default.rb +6 -14
- data/lib/vagrant.rb +132 -5
- data/lib/vagrant/action.rb +45 -123
- data/lib/vagrant/action/box/destroy.rb +7 -3
- data/lib/vagrant/action/box/download.rb +8 -8
- data/lib/vagrant/action/box/package.rb +2 -2
- data/lib/vagrant/action/box/unpackage.rb +13 -7
- data/lib/vagrant/action/box/verify.rb +5 -5
- data/lib/vagrant/action/builder.rb +23 -19
- data/lib/vagrant/action/builtin.rb +117 -79
- data/lib/vagrant/action/env/set.rb +7 -4
- data/lib/vagrant/action/environment.rb +3 -41
- data/lib/vagrant/action/general/package.rb +14 -29
- data/lib/vagrant/action/general/validate.rb +2 -2
- data/lib/vagrant/action/runner.rb +53 -0
- data/lib/vagrant/action/vm/boot.rb +9 -9
- data/lib/vagrant/action/vm/check_accessible.rb +2 -2
- data/lib/vagrant/action/vm/check_box.rb +10 -12
- data/lib/vagrant/action/vm/check_guest_additions.rb +8 -8
- data/lib/vagrant/action/vm/check_port_collisions.rb +85 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +4 -4
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +3 -11
- data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +2 -11
- data/lib/vagrant/action/vm/customize.rb +19 -9
- data/lib/vagrant/action/vm/destroy.rb +4 -4
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +2 -12
- data/lib/vagrant/action/vm/discard_state.rb +4 -4
- data/lib/vagrant/action/vm/export.rb +13 -8
- data/lib/vagrant/action/vm/forward_ports.rb +55 -102
- data/lib/vagrant/action/vm/halt.rb +9 -6
- data/lib/vagrant/action/vm/host_name.rb +4 -4
- data/lib/vagrant/action/vm/import.rb +19 -10
- data/lib/vagrant/action/vm/match_mac_address.rb +4 -9
- data/lib/vagrant/action/vm/network.rb +300 -94
- data/lib/vagrant/action/vm/nfs.rb +41 -26
- data/lib/vagrant/action/vm/package.rb +1 -1
- data/lib/vagrant/action/vm/package_vagrantfile.rb +5 -2
- data/lib/vagrant/action/vm/provision.rb +42 -13
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +2 -2
- data/lib/vagrant/action/vm/{clear_nfs_exports.rb → prune_nfs_exports.rb} +7 -7
- data/lib/vagrant/action/vm/resume.rb +4 -4
- data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
- data/lib/vagrant/action/vm/share_folders.rb +63 -39
- data/lib/vagrant/action/vm/suspend.rb +4 -4
- data/lib/vagrant/action/warden.rb +13 -6
- data/lib/vagrant/box.rb +9 -55
- data/lib/vagrant/box_collection.rb +22 -17
- data/lib/vagrant/cli.rb +62 -47
- data/lib/vagrant/command.rb +18 -20
- data/lib/vagrant/command/base.rb +135 -90
- data/lib/vagrant/command/box.rb +46 -21
- data/lib/vagrant/command/box_add.rb +33 -0
- data/lib/vagrant/command/box_list.rb +25 -0
- data/lib/vagrant/command/box_remove.rb +23 -0
- data/lib/vagrant/command/box_repackage.rb +23 -0
- data/lib/vagrant/command/destroy.rb +16 -5
- data/lib/vagrant/command/halt.rb +25 -7
- data/lib/vagrant/command/init.rb +30 -7
- data/lib/vagrant/command/package.rb +49 -18
- data/lib/vagrant/command/provision.rb +22 -9
- data/lib/vagrant/command/reload.rb +18 -5
- data/lib/vagrant/command/resume.rb +18 -5
- data/lib/vagrant/command/ssh.rb +69 -31
- data/lib/vagrant/command/ssh_config.rb +37 -22
- data/lib/vagrant/command/status.rb +22 -20
- data/lib/vagrant/command/suspend.rb +18 -5
- data/lib/vagrant/command/up.rb +41 -8
- data/lib/vagrant/communication.rb +7 -0
- data/lib/vagrant/communication/base.rb +56 -0
- data/lib/vagrant/communication/ssh.rb +200 -0
- data/lib/vagrant/config.rb +29 -103
- data/lib/vagrant/config/base.rb +18 -26
- data/lib/vagrant/config/container.rb +37 -0
- data/lib/vagrant/config/error_recorder.rb +1 -1
- data/lib/vagrant/config/loader.rb +125 -0
- data/lib/vagrant/config/nfs.rb +1 -3
- data/lib/vagrant/config/package.rb +1 -3
- data/lib/vagrant/config/ssh.rb +31 -16
- data/lib/vagrant/config/top.rb +36 -25
- data/lib/vagrant/config/vagrant.rb +2 -5
- data/lib/vagrant/config/vm.rb +115 -56
- data/lib/vagrant/config/vm/provisioner.rb +16 -20
- data/lib/vagrant/config/vm/sub_vm.rb +1 -1
- data/lib/vagrant/data_store.rb +23 -15
- data/lib/vagrant/downloaders/base.rb +7 -5
- data/lib/vagrant/downloaders/file.rb +4 -4
- data/lib/vagrant/downloaders/http.rb +4 -5
- data/lib/vagrant/driver.rb +7 -0
- data/lib/vagrant/driver/virtualbox.rb +121 -0
- data/lib/vagrant/driver/virtualbox_4_0.rb +411 -0
- data/lib/vagrant/driver/virtualbox_4_1.rb +411 -0
- data/lib/vagrant/driver/virtualbox_base.rb +284 -0
- data/lib/vagrant/environment.rb +221 -240
- data/lib/vagrant/errors.rb +74 -25
- data/lib/vagrant/guest.rb +16 -0
- data/lib/vagrant/guest/arch.rb +48 -0
- data/lib/vagrant/{systems → guest}/base.rb +30 -18
- data/lib/vagrant/guest/debian.rb +61 -0
- data/lib/vagrant/{systems → guest}/freebsd.rb +11 -18
- data/lib/vagrant/guest/gentoo.rb +32 -0
- data/lib/vagrant/guest/linux.rb +78 -0
- data/lib/vagrant/{systems → guest}/linux/config.rb +2 -4
- data/lib/vagrant/guest/linux/error.rb +9 -0
- data/lib/vagrant/guest/redhat.rb +66 -0
- data/lib/vagrant/guest/solaris.rb +114 -0
- data/lib/vagrant/{systems → guest}/suse.rb +2 -2
- data/lib/vagrant/guest/ubuntu.rb +23 -0
- data/lib/vagrant/hosts.rb +23 -6
- data/lib/vagrant/hosts/arch.rb +7 -3
- data/lib/vagrant/hosts/base.rb +36 -46
- data/lib/vagrant/hosts/bsd.rb +53 -16
- data/lib/vagrant/hosts/fedora.rb +14 -0
- data/lib/vagrant/hosts/freebsd.rb +6 -36
- data/lib/vagrant/hosts/linux.rb +45 -20
- data/lib/vagrant/hosts/windows.rb +16 -0
- data/lib/vagrant/provisioners.rb +10 -7
- data/lib/vagrant/provisioners/base.rb +11 -34
- data/lib/vagrant/provisioners/chef.rb +30 -26
- data/lib/vagrant/provisioners/chef_client.rb +37 -23
- data/lib/vagrant/provisioners/chef_solo.rb +61 -16
- data/lib/vagrant/provisioners/puppet.rb +70 -38
- data/lib/vagrant/provisioners/puppet_server.rb +12 -13
- data/lib/vagrant/provisioners/shell.rb +24 -24
- data/lib/vagrant/registry.rb +49 -0
- data/lib/vagrant/ssh.rb +82 -153
- data/lib/vagrant/ui.rb +118 -50
- data/lib/vagrant/util/busy.rb +1 -1
- data/lib/vagrant/util/file_mode.rb +12 -0
- data/lib/vagrant/util/network_ip.rb +28 -0
- data/lib/vagrant/util/platform.rb +1 -0
- data/lib/vagrant/util/subprocess.rb +227 -0
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +111 -97
- data/tasks/acceptance.rake +3 -3
- data/tasks/test.rake +7 -2
- data/templates/commands/init/Vagrantfile.erb +11 -4
- data/templates/{ssh_config.erb → commands/ssh_config/config.erb} +0 -0
- data/templates/guests/arch/network_dhcp.erb +7 -0
- data/templates/guests/arch/network_static.erb +7 -0
- data/templates/guests/debian/network_dhcp.erb +6 -0
- data/templates/guests/debian/network_static.erb +7 -0
- data/templates/guests/gentoo/network_dhcp.erb +4 -0
- data/templates/guests/gentoo/network_static.erb +4 -0
- data/templates/guests/redhat/network_dhcp.erb +6 -0
- data/templates/guests/redhat/network_static.erb +7 -0
- data/templates/locales/en.yml +241 -122
- data/templates/{chef_server_client.erb → provisioners/chef_client/client.erb} +0 -0
- data/templates/{chef_solo_solo.erb → provisioners/chef_solo/solo.erb} +0 -0
- data/test/acceptance/base.rb +10 -10
- data/test/acceptance/box_test.rb +28 -6
- data/test/acceptance/destroy_test.rb +1 -1
- data/test/acceptance/halt_test.rb +4 -4
- data/test/acceptance/init_test.rb +3 -3
- data/test/acceptance/networking/host_only_test.rb +37 -0
- data/test/acceptance/networking/port_forward_test.rb +125 -0
- data/test/acceptance/package_test.rb +46 -0
- data/test/acceptance/provisioning/basic_test.rb +61 -0
- data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
- data/test/acceptance/provisioning/shell_test.rb +53 -0
- data/test/acceptance/resume_test.rb +1 -1
- data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
- data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
- data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/ssh_test.rb +7 -2
- data/test/acceptance/support/config.rb +1 -1
- data/test/acceptance/support/isolated_environment.rb +41 -150
- data/test/acceptance/support/matchers/match_output.rb +1 -1
- data/test/acceptance/support/matchers/succeed.rb +14 -0
- data/test/acceptance/support/network_tests.rb +29 -0
- data/test/acceptance/support/output.rb +9 -1
- data/test/acceptance/support/shared/base_context.rb +16 -9
- data/test/acceptance/support/shared/command_examples.rb +4 -4
- data/test/acceptance/suspend_test.rb +1 -1
- data/test/acceptance/up_basic_test.rb +26 -7
- data/test/acceptance/up_with_box_url.rb +1 -1
- data/test/acceptance/vagrant_test.rb +1 -1
- data/test/acceptance/version_test.rb +0 -5
- data/test/support/isolated_environment.rb +46 -0
- data/test/{acceptance/support → support}/tempdir.rb +0 -0
- data/test/unit/base.rb +21 -0
- data/test/unit/support/isolated_environment.rb +39 -0
- data/test/unit/support/shared/base_context.rb +30 -0
- data/test/unit/vagrant/action/builder_test.rb +126 -177
- data/test/unit/vagrant/action/environment_test.rb +10 -21
- data/test/unit/vagrant/action/runner_test.rb +65 -0
- data/test/unit/vagrant/action/warden_test.rb +64 -97
- data/test/unit/vagrant/box_collection_test.rb +44 -33
- data/test/unit/vagrant/box_test.rb +25 -65
- data/test/unit/vagrant/command/base_test.rb +141 -14
- data/test/unit/vagrant/config/base_test.rb +16 -43
- data/test/unit/vagrant/config/loader_test.rb +79 -0
- data/test/unit/vagrant/config/top_test.rb +69 -0
- data/test/unit/vagrant/config/vm_test.rb +62 -47
- data/test/unit/vagrant/config_test.rb +16 -151
- data/test/unit/vagrant/data_store_test.rb +43 -61
- data/test/unit/vagrant/downloaders/base_test.rb +12 -22
- data/test/unit/vagrant/downloaders/file_test.rb +58 -31
- data/test/unit/vagrant/downloaders/http_test.rb +12 -86
- data/test/unit/vagrant/environment_test.rb +107 -536
- data/test/unit/vagrant/hosts_test.rb +36 -0
- data/test/unit/vagrant/registry_test.rb +56 -0
- data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
- data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +23 -24
- data/test/unit/vagrant/util/network_ip_test.rb +17 -0
- data/test/unit/vagrant/util/retryable_test.rb +90 -34
- data/test/unit/vagrant_test.rb +27 -0
- data/test/{unit → unit_legacy}/locales/en.yml +0 -0
- data/test/{unit → unit_legacy}/test_helper.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/download_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/unpackage_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/verify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/env/set_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/validate_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/boot_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_accessible_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_box_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_guest_additions_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clean_machine_folder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_nfs_exports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_shared_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/customize_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/discard_state_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/export_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/halt_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/host_name_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/import_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/match_mac_address_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/modify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/network_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_vagrantfile_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provision_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provisioner_cleanup_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/resume_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/share_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/suspend_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action_test.rb +0 -0
- data/test/unit_legacy/vagrant/box_collection_test.rb +45 -0
- data/test/unit_legacy/vagrant/box_test.rb +74 -0
- data/test/{unit → unit_legacy}/vagrant/cli_test.rb +0 -0
- data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
- data/test/{unit → unit_legacy}/vagrant/command/group_base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/init_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/package_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
- data/test/{unit → unit_legacy}/vagrant/config/error_recorder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vagrant_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vm/provisioner_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/vm_test.rb +47 -0
- data/test/unit_legacy/vagrant/config_test.rb +148 -0
- data/test/unit_legacy/vagrant/downloaders/http_test.rb +93 -0
- data/test/unit_legacy/vagrant/environment_test.rb +539 -0
- data/test/{unit → unit_legacy}/vagrant/errors_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/bsd_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/plugin_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_client_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_solo_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_server_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/shell_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh/session_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/busy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/counter_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/platform_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/stacked_proc_runner_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/template_renderer_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/vm_test.rb +0 -0
- data/vagrant.gemspec +7 -9
- metadata +214 -216
- data/keys/vagrant.ppk +0 -26
- data/lib/vagrant/action/box.rb +0 -11
- data/lib/vagrant/action/env.rb +0 -7
- data/lib/vagrant/action/general.rb +0 -8
- data/lib/vagrant/action/vm.rb +0 -34
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +0 -28
- data/lib/vagrant/action/vm/modify.rb +0 -37
- data/lib/vagrant/action/vm/nfs_helpers.rb +0 -11
- data/lib/vagrant/command/group_base.rb +0 -107
- data/lib/vagrant/command/helpers.rb +0 -33
- data/lib/vagrant/command/named_base.rb +0 -14
- data/lib/vagrant/command/upgrade_to_060.rb +0 -45
- data/lib/vagrant/command/version.rb +0 -13
- data/lib/vagrant/ssh/session.rb +0 -136
- data/lib/vagrant/systems.rb +0 -13
- data/lib/vagrant/systems/arch.rb +0 -34
- data/lib/vagrant/systems/debian.rb +0 -36
- data/lib/vagrant/systems/gentoo.rb +0 -27
- data/lib/vagrant/systems/linux.rb +0 -82
- data/lib/vagrant/systems/linux/error.rb +0 -9
- data/lib/vagrant/systems/redhat.rb +0 -48
- data/lib/vagrant/systems/solaris.rb +0 -113
- data/lib/vagrant/systems/ubuntu.rb +0 -17
- data/templates/network_entry_arch.erb +0 -9
- data/templates/network_entry_debian.erb +0 -8
- data/templates/network_entry_gentoo.erb +0 -5
- data/templates/network_entry_redhat.erb +0 -9
- data/test/unit/vagrant/ui_test.rb +0 -29
data/lib/vagrant/config.rb
CHANGED
@@ -1,46 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module Vagrant
|
2
|
+
module Config
|
3
|
+
autoload :Base, 'vagrant/config/base'
|
4
|
+
autoload :Container, 'vagrant/config/container'
|
5
|
+
autoload :ErrorRecorder, 'vagrant/config/error_recorder'
|
6
|
+
autoload :Loader, 'vagrant/config/loader'
|
7
|
+
autoload :Top, 'vagrant/config/top'
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
require 'vagrant/config/package'
|
9
|
+
autoload :NFSConfig, 'vagrant/config/nfs'
|
10
|
+
autoload :PackageConfig, 'vagrant/config/package'
|
11
|
+
autoload :SSHConfig, 'vagrant/config/ssh'
|
12
|
+
autoload :VagrantConfig, 'vagrant/config/vagrant'
|
13
|
+
autoload :VMConfig, 'vagrant/config/vm'
|
11
14
|
|
12
|
-
|
13
|
-
# The config class is responsible for loading Vagrant configurations, which
|
14
|
-
# are usually found in Vagrantfiles but may also be procs. The loading is done
|
15
|
-
# by specifying a queue of files or procs that are for configuration, and then
|
16
|
-
# executing them. The config loader will run each item in the queue, so that
|
17
|
-
# configuration from later items overwrite that from earlier items. This is how
|
18
|
-
# Vagrant "scoping" of Vagranfiles is implemented.
|
19
|
-
#
|
20
|
-
# If you're looking to create your own configuration classes, see {Base}.
|
21
|
-
#
|
22
|
-
# # Loading Configuration Files
|
23
|
-
#
|
24
|
-
# If you are in fact looking to load configuration files, then this is the
|
25
|
-
# class you are looking for. Loading configuration is quite easy. The following
|
26
|
-
# example assumes `env` is already a loaded instance of {Environment}:
|
27
|
-
#
|
28
|
-
# config = Vagrant::Config.new
|
29
|
-
# config.set(:first, "/path/to/some/Vagrantfile")
|
30
|
-
# config.set(:second, "/path/to/another/Vagrantfile")
|
31
|
-
# config.load_order = [:first, :second]
|
32
|
-
# result = config.load(env)
|
33
|
-
#
|
34
|
-
# p "Your box is: #{result.vm.box}"
|
35
|
-
#
|
36
|
-
# The load order determines what order the config files specified are loaded.
|
37
|
-
# If a key is not mentioned (for example if above the load order was set to
|
38
|
-
# `[:first]`, therefore `:second` was not mentioned), then that config file
|
39
|
-
# won't be loaded.
|
40
|
-
class Config
|
41
|
-
# An array of symbols specifying the load order for the procs.
|
42
|
-
attr_accessor :load_order
|
43
|
-
attr_reader :procs
|
15
|
+
CONFIGURE_MUTEX = Mutex.new
|
44
16
|
|
45
17
|
# This is the method which is called by all Vagrantfiles to configure Vagrant.
|
46
18
|
# This method expects a block which accepts a single argument representing
|
@@ -54,69 +26,23 @@ module Vagrant
|
|
54
26
|
@last_procs << block
|
55
27
|
end
|
56
28
|
|
57
|
-
#
|
58
|
-
#
|
59
|
-
# will not return duplicates.
|
60
|
-
#
|
61
|
-
# @return [Proc]
|
62
|
-
def self.last_proc
|
63
|
-
value = @last_procs
|
64
|
-
@last_procs = nil
|
65
|
-
value
|
66
|
-
end
|
67
|
-
|
68
|
-
def initialize(parent=nil)
|
69
|
-
@procs = {}
|
70
|
-
@load_order = []
|
71
|
-
|
72
|
-
if parent
|
73
|
-
# Shallow copy the procs and load order from parent if given
|
74
|
-
@procs = parent.procs.dup
|
75
|
-
@load_order = parent.load_order.dup
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# Adds a Vagrantfile to be loaded to the queue of config procs. Note
|
80
|
-
# that this causes the Vagrantfile file to be loaded at this point,
|
81
|
-
# and it will never be loaded again.
|
82
|
-
def set(key, path)
|
83
|
-
return if @procs.has_key?(key)
|
84
|
-
@procs[key] = [path].flatten.map(&method(:proc_for)).flatten
|
85
|
-
end
|
86
|
-
|
87
|
-
# Loads the added procs using the set `load_order` attribute and returns
|
88
|
-
# the {Config::Top} object result. The configuration is loaded for the
|
89
|
-
# given {Environment} object.
|
29
|
+
# This is a method which will yield to a block and will capture all
|
30
|
+
# ``Vagrant.configure`` calls, returning an array of `Proc`s.
|
90
31
|
#
|
91
|
-
#
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
config
|
106
|
-
end
|
107
|
-
|
108
|
-
protected
|
109
|
-
|
110
|
-
def proc_for(path)
|
111
|
-
return nil if !path
|
112
|
-
return path if path.is_a?(Proc)
|
113
|
-
|
114
|
-
begin
|
115
|
-
Kernel.load path if File.exist?(path)
|
116
|
-
return self.class.last_proc
|
117
|
-
rescue SyntaxError => e
|
118
|
-
# Report syntax errors in a nice way for Vagrantfiles
|
119
|
-
raise Errors::VagrantfileSyntaxError, :file => e.message
|
32
|
+
# Wrapping this around anytime you call code which loads configurations
|
33
|
+
# will force a mutex so that procs never get mixed up. This keeps
|
34
|
+
# the configuration loading part of Vagrant thread-safe.
|
35
|
+
def self.capture_configures
|
36
|
+
CONFIGURE_MUTEX.synchronize do
|
37
|
+
# Reset the last procs so that we start fresh
|
38
|
+
@last_procs = []
|
39
|
+
|
40
|
+
# Yield to allow the caller to do whatever loading needed
|
41
|
+
yield
|
42
|
+
|
43
|
+
# Return the last procs we've seen while still in the mutex,
|
44
|
+
# knowing we're safe.
|
45
|
+
return @last_procs
|
120
46
|
end
|
121
47
|
end
|
122
48
|
end
|
data/lib/vagrant/config/base.rb
CHANGED
@@ -1,22 +1,9 @@
|
|
1
1
|
module Vagrant
|
2
|
-
|
2
|
+
module Config
|
3
3
|
# The base class for all configuration classes. This implements
|
4
4
|
# basic things such as the environment instance variable which all
|
5
5
|
# config classes need as well as a basic `to_json` implementation.
|
6
6
|
class Base
|
7
|
-
# {Top} of this configuration stack
|
8
|
-
attr_accessor :top
|
9
|
-
|
10
|
-
# Registers a subclass with the Vagrant configuration system so
|
11
|
-
# that it can then be used in Vagrantfiles.
|
12
|
-
#
|
13
|
-
# @param [Symbol] accessor The accessor on the main config object
|
14
|
-
# that is used to access the configuration class.
|
15
|
-
#
|
16
|
-
def self.configures(accessor, klass=self)
|
17
|
-
Top.configures(accessor, klass)
|
18
|
-
end
|
19
|
-
|
20
7
|
# Loads configuration values from JSON back into the proper
|
21
8
|
# configuration classes. By default, this is done by simply
|
22
9
|
# iterating over all values in the JSON hash and assigning them
|
@@ -29,14 +16,6 @@ module Vagrant
|
|
29
16
|
end
|
30
17
|
end
|
31
18
|
|
32
|
-
# A helper to access the environment that this configuration is for.
|
33
|
-
# This is obtained by getting the env from the {Top}.
|
34
|
-
#
|
35
|
-
# @return [Vagrant::Envrionment]
|
36
|
-
def env
|
37
|
-
top.env
|
38
|
-
end
|
39
|
-
|
40
19
|
# Allows setting options from a hash. By default this simply calls
|
41
20
|
# the `#{key}=` method on the config class with the value, which is
|
42
21
|
# the expected behavior most of the time.
|
@@ -46,12 +25,26 @@ module Vagrant
|
|
46
25
|
end
|
47
26
|
end
|
48
27
|
|
28
|
+
# Merge another configuration object into this one.
|
29
|
+
#
|
30
|
+
# @param [Object] other The other configuration object to merge from,
|
31
|
+
# this must be the same type of object as this one.
|
32
|
+
# @return [Object] The merged object.
|
33
|
+
def merge(other)
|
34
|
+
result = self.class.new
|
35
|
+
instance_variables_hash.merge(other.instance_variables_hash).each do |key, value|
|
36
|
+
result.instance_variable_set("@#{key}".to_sym, value)
|
37
|
+
end
|
38
|
+
|
39
|
+
result
|
40
|
+
end
|
41
|
+
|
49
42
|
# Called by {Top} after the configuration is loaded to validate
|
50
43
|
# the configuaration objects. Subclasses should implement this
|
51
44
|
# method and add any errors to the `errors` object given.
|
52
45
|
#
|
53
46
|
# @param [ErrorRecorder] errors
|
54
|
-
def validate(errors); end
|
47
|
+
def validate(env, errors); end
|
55
48
|
|
56
49
|
# Converts the configuration to a raw hash by calling `#to_hash`
|
57
50
|
# on all instance variables (if it can) and putting them into
|
@@ -69,14 +62,13 @@ module Vagrant
|
|
69
62
|
# the JSON is parsed back, it can be loaded back into the proper class.
|
70
63
|
# See {json_create}.
|
71
64
|
def to_json(*a)
|
72
|
-
|
73
|
-
result.merge(instance_variables_hash).to_json(*a)
|
65
|
+
instance_variables_hash.to_json(*a)
|
74
66
|
end
|
75
67
|
|
76
68
|
# Returns the instance variables as a hash of key-value pairs.
|
77
69
|
def instance_variables_hash
|
78
70
|
instance_variables.inject({}) do |acc, iv|
|
79
|
-
acc[iv.to_s[1..-1]] = instance_variable_get(iv)
|
71
|
+
acc[iv.to_s[1..-1]] = instance_variable_get(iv)
|
80
72
|
acc
|
81
73
|
end
|
82
74
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Config
|
3
|
+
# Contains loaded configuration values and provides access to those
|
4
|
+
# values.
|
5
|
+
#
|
6
|
+
# This is the class returned when loading configuration and stores
|
7
|
+
# the completely loaded configuration values. This class is meant to
|
8
|
+
# be immutable.
|
9
|
+
class Container
|
10
|
+
attr_reader :global
|
11
|
+
attr_reader :vms
|
12
|
+
|
13
|
+
# Initializes the configuration container.
|
14
|
+
#
|
15
|
+
# @param [Top] global Top-level configuration for the global
|
16
|
+
# applicatoin.
|
17
|
+
# @param [Array] vms Array of VM configurations.
|
18
|
+
def initialize(global, vms)
|
19
|
+
@global = global
|
20
|
+
@vms = []
|
21
|
+
@vm_configs = {}
|
22
|
+
|
23
|
+
vms.each do |vm_config|
|
24
|
+
@vms << vm_config.vm.name
|
25
|
+
@vm_configs[vm_config.vm.name] = vm_config
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# This returns the configuration for a specific virtual machine.
|
30
|
+
# The values for this configuration are usually pertinent to a
|
31
|
+
# single virtual machine and do not affect the system globally.
|
32
|
+
def for_vm(name)
|
33
|
+
@vm_configs[name]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "log4r"
|
4
|
+
|
5
|
+
module Vagrant
|
6
|
+
module Config
|
7
|
+
# This class is responsible for loading Vagrant configuration,
|
8
|
+
# usually in the form of Vagrantfiles.
|
9
|
+
#
|
10
|
+
# Loading works by specifying the sources for the configuration
|
11
|
+
# as well as the order the sources should be loaded. Configuration
|
12
|
+
# set later always overrides those set earlier; this is how
|
13
|
+
# configuration "scoping" is implemented.
|
14
|
+
class Loader
|
15
|
+
# This is an array of symbols specifying the order in which
|
16
|
+
# configuration is loaded. For examples, see the class documentation.
|
17
|
+
attr_accessor :load_order
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@logger = Log4r::Logger.new("vagrant::config::loader")
|
21
|
+
@sources = {}
|
22
|
+
@proc_cache = {}
|
23
|
+
@config_cache = {}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Set the configuration data for the given name.
|
27
|
+
#
|
28
|
+
# The `name` should be a symbol and must uniquely identify the data
|
29
|
+
# being given.
|
30
|
+
#
|
31
|
+
# `data` can either be a path to a Ruby Vagrantfile or a `Proc` directly.
|
32
|
+
# `data` can also be an array of such values.
|
33
|
+
#
|
34
|
+
# At this point, no configuration is actually loaded. Note that calling
|
35
|
+
# `set` multiple times with the same name will override any previously
|
36
|
+
# set values. In this way, the last set data for a given name wins.
|
37
|
+
def set(name, sources)
|
38
|
+
@logger.debug("Set #{name.inspect} = #{sources.inspect}")
|
39
|
+
|
40
|
+
# Sources should be an array
|
41
|
+
sources = [sources] if !sources.kind_of?(Array)
|
42
|
+
|
43
|
+
# Gather the procs for every source, since that is what we care about.
|
44
|
+
procs = []
|
45
|
+
sources.each do |source|
|
46
|
+
if !@proc_cache.has_key?(source)
|
47
|
+
# Load the procs for this source and cache them. This caching
|
48
|
+
# avoids the issue where a file may have side effects when loading
|
49
|
+
# and loading it multiple times causes unexpected behavior.
|
50
|
+
@logger.debug("Populating proc cache for #{source.inspect}")
|
51
|
+
@proc_cache[source] = procs_for_source(source)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Add on to the array of procs we're going to use
|
55
|
+
procs.concat(@proc_cache[source])
|
56
|
+
end
|
57
|
+
|
58
|
+
# Set this source by name.
|
59
|
+
@sources[name] = procs
|
60
|
+
end
|
61
|
+
|
62
|
+
# This loads the configured sources in the configured order and returns
|
63
|
+
# an actual configuration object that is ready to be used.
|
64
|
+
def load
|
65
|
+
@logger.debug("Loading configuration in order: #{@load_order.inspect}")
|
66
|
+
|
67
|
+
unknown_sources = @sources.keys - @load_order
|
68
|
+
if !unknown_sources.empty?
|
69
|
+
# TODO: Raise exception here perhaps.
|
70
|
+
@logger.error("Unknown config sources: #{unknown_sources.inspect}")
|
71
|
+
end
|
72
|
+
|
73
|
+
# Create the top-level configuration which will hold all the config.
|
74
|
+
result = Top.new
|
75
|
+
|
76
|
+
@load_order.each do |key|
|
77
|
+
next if !@sources.has_key?(key)
|
78
|
+
|
79
|
+
@sources[key].each do |proc|
|
80
|
+
if !@config_cache.has_key?(proc)
|
81
|
+
@logger.debug("Loading from: #{key} (evaluating)")
|
82
|
+
current = Top.new
|
83
|
+
proc.call(current)
|
84
|
+
@config_cache[proc] = current
|
85
|
+
end
|
86
|
+
|
87
|
+
# Merge in the results of this proc's configuration
|
88
|
+
result = result.merge(@config_cache[proc])
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
@logger.debug("Configuration loaded successfully")
|
93
|
+
result
|
94
|
+
end
|
95
|
+
|
96
|
+
protected
|
97
|
+
|
98
|
+
# This returns an array of `Proc` objects for the given source.
|
99
|
+
# The `Proc` objects returned will expect a single argument for
|
100
|
+
# the configuration object and are expected to mutate this
|
101
|
+
# configuration object.
|
102
|
+
def procs_for_source(source)
|
103
|
+
return [source] if source.is_a?(Proc)
|
104
|
+
|
105
|
+
# Assume all string sources are actually pathnames
|
106
|
+
source = Pathname.new(source) if source.is_a?(String)
|
107
|
+
|
108
|
+
if source.is_a?(Pathname)
|
109
|
+
@logger.debug("Load procs for pathname: #{source.inspect}")
|
110
|
+
|
111
|
+
begin
|
112
|
+
return Config.capture_configures do
|
113
|
+
Kernel.load source
|
114
|
+
end
|
115
|
+
rescue SyntaxError => e
|
116
|
+
# Report syntax errors in a nice way.
|
117
|
+
raise Errors::VagrantfileSyntaxError, :file => e.message
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
raise Exception, "Unknown configuration source: #{source.inspect}"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
data/lib/vagrant/config/nfs.rb
CHANGED
data/lib/vagrant/config/ssh.rb
CHANGED
@@ -1,37 +1,52 @@
|
|
1
1
|
module Vagrant
|
2
|
-
|
2
|
+
module Config
|
3
3
|
class SSHConfig < Base
|
4
|
-
configures :ssh
|
5
|
-
|
6
4
|
attr_accessor :username
|
5
|
+
attr_accessor :password
|
7
6
|
attr_accessor :host
|
8
|
-
attr_accessor :
|
9
|
-
attr_accessor :
|
7
|
+
attr_accessor :port
|
8
|
+
attr_accessor :guest_port
|
10
9
|
attr_accessor :max_tries
|
11
10
|
attr_accessor :timeout
|
12
|
-
|
11
|
+
attr_accessor :private_key_path
|
13
12
|
attr_accessor :forward_agent
|
14
13
|
attr_accessor :forward_x11
|
15
14
|
attr_accessor :shell
|
16
|
-
attr_accessor :port
|
17
15
|
|
18
16
|
def initialize
|
19
|
-
@shell
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@forward_x11 = false
|
17
|
+
@shell = "bash"
|
18
|
+
@forward_agent = false
|
19
|
+
@forward_x11 = false
|
23
20
|
end
|
24
21
|
|
25
|
-
def
|
26
|
-
|
22
|
+
def forwarded_port_key=(value)
|
23
|
+
raise Errors::DeprecationError, :message => <<-MESSAGE
|
24
|
+
`config.ssh.forwarded_port_key` is now gone. You must now use
|
25
|
+
`config.ssh.guest_port` which is expected to be the port on the
|
26
|
+
guest that SSH is listening on. Vagrant will automatically scan
|
27
|
+
the forwarded ports to look for a forwarded port from this port
|
28
|
+
and use it.
|
29
|
+
MESSAGE
|
27
30
|
end
|
28
31
|
|
29
|
-
def
|
30
|
-
|
32
|
+
def forwarded_port_destination=(value)
|
33
|
+
raise Errors::DeprecationError, :message => <<-MESSAGE
|
34
|
+
`config.ssh.forwarded_port_destination` is now gone. You must now use
|
35
|
+
`config.ssh.guest_port` which is expected to be the port on the
|
36
|
+
guest that SSH is listening on. Vagrant will automatically scan
|
37
|
+
the forwarded ports to look for a forwarded port from this port
|
38
|
+
and use it.
|
39
|
+
MESSAGE
|
40
|
+
end
|
41
|
+
|
42
|
+
def validate(env, errors)
|
43
|
+
[:username, :host, :max_tries, :timeout].each do |field|
|
31
44
|
errors.add(I18n.t("vagrant.config.common.error_empty", :field => field)) if !instance_variable_get("@#{field}".to_sym)
|
32
45
|
end
|
33
46
|
|
34
|
-
|
47
|
+
if private_key_path && !File.file?(private_key_path)
|
48
|
+
errors.add(I18n.t("vagrant.config.ssh.private_key_missing", :path => private_key_path))
|
49
|
+
end
|
35
50
|
end
|
36
51
|
end
|
37
52
|
end
|