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
@@ -5,8 +5,6 @@ module Vagrant
|
|
5
5
|
end
|
6
6
|
|
7
7
|
class PuppetServer < Base
|
8
|
-
register :puppet_server
|
9
|
-
|
10
8
|
class Config < Vagrant::Config::Base
|
11
9
|
attr_accessor :puppet_server
|
12
10
|
attr_accessor :puppet_node
|
@@ -19,15 +17,20 @@ module Vagrant
|
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
20
|
+
def self.config_class
|
21
|
+
Config
|
22
|
+
end
|
23
|
+
|
22
24
|
def provision!
|
23
25
|
verify_binary("puppetd")
|
24
26
|
run_puppetd_client
|
25
27
|
end
|
26
28
|
|
27
29
|
def verify_binary(binary)
|
28
|
-
vm.
|
29
|
-
|
30
|
-
|
30
|
+
env[:vm].channel.sudo("which #{binary}",
|
31
|
+
:error_class => PuppetServerError,
|
32
|
+
:error_key => :puppetd_not_detected,
|
33
|
+
:binary => binary)
|
31
34
|
end
|
32
35
|
|
33
36
|
def run_puppetd_client
|
@@ -36,18 +39,14 @@ module Vagrant
|
|
36
39
|
if config.puppet_node
|
37
40
|
cn = config.puppet_node
|
38
41
|
else
|
39
|
-
cn = env.config.vm.box
|
42
|
+
cn = env[:vm].config.vm.box
|
40
43
|
end
|
41
44
|
|
42
|
-
|
45
|
+
command = "puppetd #{options} --server #{config.puppet_server} --certname #{cn}"
|
43
46
|
|
44
47
|
env.ui.info I18n.t("vagrant.provisioners.puppet_server.running_puppetd")
|
45
|
-
|
46
|
-
|
47
|
-
ssh.sudo!(commands) do |channel, type, data|
|
48
|
-
ssh.check_exit_status(data, commands) if type == :exit_status
|
49
|
-
env.ui.info(data) if type != :exit_status
|
50
|
-
end
|
48
|
+
env[:vm].channel.sudo(command) do |type, data|
|
49
|
+
env.ui.info(data)
|
51
50
|
end
|
52
51
|
end
|
53
52
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module Provisioners
|
3
5
|
class Shell < Base
|
4
|
-
register :shell
|
5
|
-
|
6
6
|
class Config < Vagrant::Config::Base
|
7
7
|
attr_accessor :inline
|
8
8
|
attr_accessor :path
|
@@ -10,19 +10,10 @@ module Vagrant
|
|
10
10
|
attr_accessor :args
|
11
11
|
|
12
12
|
def initialize
|
13
|
-
@inline = nil
|
14
|
-
@path = nil
|
15
13
|
@upload_path = "/tmp/vagrant-shell"
|
16
|
-
@args = nil
|
17
14
|
end
|
18
15
|
|
19
|
-
def
|
20
|
-
Pathname.new(path).expand_path(env.root_path) if path
|
21
|
-
end
|
22
|
-
|
23
|
-
def validate(errors)
|
24
|
-
super
|
25
|
-
|
16
|
+
def validate(env, errors)
|
26
17
|
# Validate that the parameters are properly set
|
27
18
|
if path && inline
|
28
19
|
errors.add(I18n.t("vagrant.provisioners.shell.path_and_inline_set"))
|
@@ -31,8 +22,12 @@ module Vagrant
|
|
31
22
|
end
|
32
23
|
|
33
24
|
# Validate the existence of a script to upload
|
34
|
-
if path
|
35
|
-
|
25
|
+
if path
|
26
|
+
expanded_path = Pathname.new(path).expand_path(env.root_path)
|
27
|
+
if !expanded_path.file?
|
28
|
+
errors.add(I18n.t("vagrant.provisioners.shell.path_invalid",
|
29
|
+
:path => expanded_path))
|
30
|
+
end
|
36
31
|
end
|
37
32
|
|
38
33
|
# There needs to be a path to upload the script to
|
@@ -47,13 +42,17 @@ module Vagrant
|
|
47
42
|
end
|
48
43
|
end
|
49
44
|
|
45
|
+
def self.config_class
|
46
|
+
Config
|
47
|
+
end
|
48
|
+
|
50
49
|
# This method yields the path to a script to upload and execute
|
51
50
|
# on the remote server. This method will properly clean up the
|
52
51
|
# script file if needed.
|
53
52
|
def with_script_file
|
54
53
|
if config.path
|
55
54
|
# Just yield the path to that file...
|
56
|
-
yield config.
|
55
|
+
yield Pathname.new(config.path).expand_path(env[:root_path])
|
57
56
|
return
|
58
57
|
end
|
59
58
|
|
@@ -73,20 +72,21 @@ module Vagrant
|
|
73
72
|
def provision!
|
74
73
|
args = ""
|
75
74
|
args = " #{config.args}" if config.args
|
76
|
-
|
75
|
+
command = "chmod +x #{config.upload_path} && #{config.upload_path}#{args}"
|
77
76
|
|
78
77
|
with_script_file do |path|
|
79
78
|
# Upload the script to the VM
|
80
|
-
vm.
|
79
|
+
env[:vm].channel.upload(path.to_s, config.upload_path)
|
81
80
|
|
82
81
|
# Execute it with sudo
|
83
|
-
vm.
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
82
|
+
env[:vm].channel.sudo(command) do |type, data|
|
83
|
+
if [:stderr, :stdout].include?(type)
|
84
|
+
# Output the data with the proper color based on the stream.
|
85
|
+
color = type == :stdout ? :green : :red
|
86
|
+
|
87
|
+
# Note: Be sure to chomp the data to avoid the newlines that the
|
88
|
+
# Chef outputs.
|
89
|
+
env[:ui].info(data.chomp, :color => color, :prefix => false)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Vagrant
|
2
|
+
# Register components in a single location that can be queried.
|
3
|
+
#
|
4
|
+
# This allows certain components (such as guest systems, configuration
|
5
|
+
# pieces, etc.) to be registered and queried.
|
6
|
+
class Registry
|
7
|
+
def initialize
|
8
|
+
@actions = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
# Register a callable by key.
|
12
|
+
#
|
13
|
+
# The callable should be given in a block which will be lazily evaluated
|
14
|
+
# when the action is needed.
|
15
|
+
#
|
16
|
+
# If an action by the given name already exists then it will be
|
17
|
+
# overwritten.
|
18
|
+
def register(key, value=nil, &block)
|
19
|
+
block = lambda { value } if value
|
20
|
+
@actions[key] = block
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get an action by the given key.
|
24
|
+
#
|
25
|
+
# This will evaluate the block given to `register` and return the resulting
|
26
|
+
# action stack.
|
27
|
+
def get(key)
|
28
|
+
return nil if !@actions.has_key?(key)
|
29
|
+
@actions[key].call
|
30
|
+
end
|
31
|
+
|
32
|
+
# Iterate over the keyspace.
|
33
|
+
def each(&block)
|
34
|
+
@actions.each do |key, _|
|
35
|
+
yield key, get(key)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Converts this registry to a hash
|
40
|
+
def to_hash
|
41
|
+
result = {}
|
42
|
+
self.each do |key, value|
|
43
|
+
result[key] = value
|
44
|
+
end
|
45
|
+
|
46
|
+
result
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/vagrant/ssh.rb
CHANGED
@@ -1,194 +1,123 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'log4r'
|
2
|
+
|
3
|
+
require 'vagrant/util/file_mode'
|
4
|
+
require 'vagrant/util/platform'
|
5
|
+
require 'vagrant/util/safe_exec'
|
3
6
|
|
4
7
|
module Vagrant
|
5
|
-
# Manages SSH
|
6
|
-
#
|
7
|
-
# upload files, or even check if a host is up.
|
8
|
+
# Manages SSH connection information as well as allows opening an
|
9
|
+
# SSH connection.
|
8
10
|
class SSH
|
9
|
-
# Autoload this guy because he is really only used in one location
|
10
|
-
# and not for every Vagrant command.
|
11
|
-
autoload :Session, 'vagrant/ssh/session'
|
12
|
-
|
13
|
-
include Util::Retryable
|
14
11
|
include Util::SafeExec
|
15
12
|
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
def initialize(vm)
|
14
|
+
@vm = vm
|
15
|
+
@logger = Log4r::Logger.new("vagrant::ssh")
|
16
|
+
end
|
19
17
|
|
20
|
-
|
21
|
-
|
18
|
+
# Returns a hash of information necessary for accessing this
|
19
|
+
# virtual machine via SSH.
|
20
|
+
#
|
21
|
+
# @return [Hash]
|
22
|
+
def info
|
23
|
+
results = {
|
24
|
+
:host => @vm.config.ssh.host,
|
25
|
+
:port => @vm.config.ssh.port || @vm.driver.ssh_port(@vm.config.ssh.guest_port),
|
26
|
+
:username => @vm.config.ssh.username,
|
27
|
+
:forward_agent => @vm.config.ssh.forward_agent,
|
28
|
+
:forward_x11 => @vm.config.ssh.forward_x11
|
29
|
+
}
|
30
|
+
|
31
|
+
# This can happen if no port is set and for some reason Vagrant
|
32
|
+
# can't detect an SSH port.
|
33
|
+
raise Errors::SSHPortNotDetected if !results[:port]
|
34
|
+
|
35
|
+
# Determine the private key path, which is either set by the
|
36
|
+
# configuration or uses just the built-in insecure key.
|
37
|
+
pk_path = @vm.config.ssh.private_key_path || @vm.env.default_private_key_path
|
38
|
+
results[:private_key_path] = File.expand_path(pk_path, @vm.env.root_path)
|
39
|
+
|
40
|
+
# We need to check and fix the private key permissions
|
41
|
+
# to make sure that SSH gets a key with 0600 perms.
|
42
|
+
check_key_permissions(results[:private_key_path])
|
43
|
+
|
44
|
+
# Return the results
|
45
|
+
return results
|
22
46
|
end
|
23
47
|
|
24
48
|
# Connects to the environment's virtual machine, replacing the ruby
|
25
|
-
# process with an SSH process.
|
26
|
-
#
|
27
|
-
|
49
|
+
# process with an SSH process.
|
50
|
+
#
|
51
|
+
# @param [Hash] opts Options hash
|
52
|
+
# @options opts [Boolean] :plain_mode If True, doesn't authenticate with
|
53
|
+
# the machine, only connects, allowing the user to connect.
|
54
|
+
def exec(opts={})
|
55
|
+
# Get the SSH information and cache it here
|
56
|
+
ssh_info = info
|
57
|
+
|
28
58
|
if Util::Platform.windows?
|
29
|
-
raise Errors::SSHUnavailableWindows, :
|
30
|
-
:
|
59
|
+
raise Errors::SSHUnavailableWindows, :host => ssh_info[:host],
|
60
|
+
:port => ssh_info[:port],
|
61
|
+
:username => ssh_info[:username],
|
62
|
+
:key_path => ssh_info[:private_key_path]
|
31
63
|
end
|
32
64
|
|
33
65
|
raise Errors::SSHUnavailable if !Kernel.system("which ssh > /dev/null 2>&1")
|
34
66
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
options[param] = opts[param] || env.config.ssh.send(param)
|
39
|
-
end
|
67
|
+
# If plain mode is enabled then we don't do any authentication (we don't
|
68
|
+
# set a user or an identity file)
|
69
|
+
plain_mode = opts[:plain_mode]
|
40
70
|
|
41
|
-
|
71
|
+
options = {}
|
72
|
+
options[:host] = ssh_info[:host]
|
73
|
+
options[:port] = ssh_info[:port]
|
74
|
+
options[:username] = ssh_info[:username]
|
75
|
+
options[:private_key_path] = ssh_info[:private_key_path]
|
42
76
|
|
43
77
|
# Command line options
|
44
78
|
command_options = ["-p #{options[:port]}", "-o UserKnownHostsFile=/dev/null",
|
45
79
|
"-o StrictHostKeyChecking=no", "-o IdentitiesOnly=yes",
|
46
|
-
"-
|
47
|
-
command_options << "-
|
80
|
+
"-o LogLevel=ERROR"]
|
81
|
+
command_options << "-i #{options[:private_key_path]}" if !plain_mode
|
82
|
+
command_options << "-o ForwardAgent=yes" if ssh_info[:forward_agent]
|
83
|
+
|
84
|
+
# If there are extra options, then we append those
|
85
|
+
command_options.concat(opts[:extra_args]) if opts[:extra_args]
|
48
86
|
|
49
|
-
if
|
87
|
+
if ssh_info[:forward_x11]
|
50
88
|
# Both are required so that no warnings are shown regarding X11
|
51
89
|
command_options << "-o ForwardX11=yes"
|
52
90
|
command_options << "-o ForwardX11Trusted=yes"
|
53
91
|
end
|
54
92
|
|
55
|
-
|
56
|
-
|
93
|
+
host_string = options[:host]
|
94
|
+
host_string = "#{options[:username]}@#{host_string}" if !plain_mode
|
95
|
+
command = "ssh #{command_options.join(" ")} #{host_string}".strip
|
96
|
+
@logger.info("Invoking SSH: #{command}")
|
57
97
|
safe_exec(command)
|
58
98
|
end
|
59
99
|
|
60
|
-
#
|
61
|
-
#
|
62
|
-
def execute(opts={})
|
63
|
-
# Check the key permissions to avoid SSH hangs
|
64
|
-
check_key_permissions(env.config.ssh.private_key_path)
|
65
|
-
|
66
|
-
# Merge in any additional options
|
67
|
-
opts = opts.dup
|
68
|
-
opts[:forward_agent] = true if env.config.ssh.forward_agent
|
69
|
-
opts[:port] ||= port
|
70
|
-
|
71
|
-
env.logger.info("ssh") { "Connecting to SSH: #{env.config.ssh.host} #{opts[:port]}" }
|
72
|
-
|
73
|
-
# The exceptions which are acceptable to retry on during
|
74
|
-
# attempts to connect to SSH
|
75
|
-
exceptions = [Errno::ECONNREFUSED, Net::SSH::Disconnect]
|
76
|
-
|
77
|
-
# Connect to SSH and gather the session
|
78
|
-
session = retryable(:tries => env.config.ssh.max_tries, :on => exceptions) do
|
79
|
-
connection = Net::SSH.start(env.config.ssh.host,
|
80
|
-
env.config.ssh.username,
|
81
|
-
opts.merge( :keys => [env.config.ssh.private_key_path],
|
82
|
-
:keys_only => true,
|
83
|
-
:user_known_hosts_file => [],
|
84
|
-
:paranoid => false,
|
85
|
-
:config => false))
|
86
|
-
SSH::Session.new(connection, env)
|
87
|
-
end
|
88
|
-
|
89
|
-
# Yield our session for executing
|
90
|
-
return yield session if block_given?
|
91
|
-
rescue Errno::ECONNREFUSED
|
92
|
-
raise Errors::SSHConnectionRefused
|
93
|
-
end
|
94
|
-
|
95
|
-
# Uploads a file from `from` to `to`. `from` is expected to be a filename
|
96
|
-
# or StringIO, and `to` is expected to be a path. This method simply forwards
|
97
|
-
# the arguments to `Net::SCP#upload!` so view that for more information.
|
98
|
-
def upload!(from, to)
|
99
|
-
retryable(:tries => 5, :on => IOError) do
|
100
|
-
execute do |ssh|
|
101
|
-
scp = Net::SCP.new(ssh.session)
|
102
|
-
scp.upload!(from, to)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
# Checks if this environment's machine is up (i.e. responding to SSH).
|
108
|
-
#
|
109
|
-
# @return [Boolean]
|
110
|
-
def up?
|
111
|
-
# We have to determine the port outside of the block since it uses
|
112
|
-
# API calls which can only be used from the main thread in JRuby on
|
113
|
-
# Windows
|
114
|
-
ssh_port = port
|
115
|
-
|
116
|
-
require 'timeout'
|
117
|
-
Timeout.timeout(env.config.ssh.timeout) do
|
118
|
-
execute(:timeout => env.config.ssh.timeout, :port => ssh_port) { |ssh| }
|
119
|
-
end
|
120
|
-
|
121
|
-
true
|
122
|
-
rescue Net::SSH::AuthenticationFailed
|
123
|
-
raise Errors::SSHAuthenticationFailed
|
124
|
-
rescue Timeout::Error, Errno::ECONNREFUSED, Net::SSH::Disconnect,
|
125
|
-
Errors::SSHConnectionRefused
|
126
|
-
return false
|
127
|
-
end
|
128
|
-
|
129
|
-
# Checks the file permissions for the private key, resetting them
|
130
|
-
# if needed, or on failure erroring.
|
100
|
+
# Checks the file permissions for a private key, resetting them
|
101
|
+
# if needed.
|
131
102
|
def check_key_permissions(key_path)
|
132
103
|
# Windows systems don't have this issue
|
133
104
|
return if Util::Platform.windows?
|
134
105
|
|
135
|
-
|
136
|
-
|
106
|
+
@logger.debug("Checking key permissions: #{key_path}")
|
137
107
|
stat = File.stat(key_path)
|
138
108
|
|
139
|
-
if stat.owned? &&
|
140
|
-
|
141
|
-
|
109
|
+
if stat.owned? && Util::FileMode.from_octal(stat.mode) != "600"
|
110
|
+
@logger.info("Attempting to correct key permissions to 0600")
|
142
111
|
File.chmod(0600, key_path)
|
143
|
-
raise Errors::SSHKeyBadPermissions, :key_path => key_path if file_perms(key_path) != "600"
|
144
|
-
end
|
145
|
-
rescue Errno::EPERM
|
146
|
-
# This shouldn't happen since we verify we own the file, but just
|
147
|
-
# in case.
|
148
|
-
raise Errors::SSHKeyBadPermissions, :key_path => key_path
|
149
|
-
end
|
150
112
|
|
151
|
-
|
152
|
-
|
153
|
-
def file_perms(path)
|
154
|
-
perms = sprintf("%o", File.stat(path).mode)
|
155
|
-
perms.reverse[0..2].reverse
|
156
|
-
end
|
157
|
-
|
158
|
-
# Returns the port which is either given in the options hash or taken from
|
159
|
-
# the config by finding it in the forwarded ports hash based on the
|
160
|
-
# `config.ssh.forwarded_port_key`.
|
161
|
-
def port(opts={})
|
162
|
-
# Check if port was specified in options hash
|
163
|
-
return opts[:port] if opts[:port]
|
164
|
-
|
165
|
-
# Check if a port was specified in the config
|
166
|
-
return env.config.ssh.port if env.config.ssh.port
|
167
|
-
|
168
|
-
# Check if we have an SSH forwarded port
|
169
|
-
pnum_by_name = nil
|
170
|
-
pnum_by_destination = nil
|
171
|
-
env.vm.vm.network_adapters.each do |na|
|
172
|
-
# Look for the port number by name...
|
173
|
-
pnum_by_name = na.nat_driver.forwarded_ports.detect do |fp|
|
174
|
-
fp.name == env.config.ssh.forwarded_port_key
|
113
|
+
if Util::FileMode.from_octal(stat.mode) != "600"
|
114
|
+
raise Errors::SSHKeyBadPermissions, :key_path => key_path
|
175
115
|
end
|
176
|
-
|
177
|
-
# Look for the port number by destination...
|
178
|
-
pnum_by_destination = na.nat_driver.forwarded_ports.detect do |fp|
|
179
|
-
fp.guestport == env.config.ssh.forwarded_port_destination
|
180
|
-
end
|
181
|
-
|
182
|
-
# pnum_by_name is what we're looking for here, so break early
|
183
|
-
# if we have it.
|
184
|
-
break if pnum_by_name
|
185
116
|
end
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
# This should NEVER happen.
|
191
|
-
raise Errors::SSHPortNotDetected
|
117
|
+
rescue Errno::EPERM
|
118
|
+
# This shouldn't happen since we verified we own the file, but
|
119
|
+
# it is possible in theory, so we raise an error.
|
120
|
+
raise Errors::SSHKeyBadPermissions, :key_path => key_path
|
192
121
|
end
|
193
122
|
end
|
194
123
|
end
|