vagrant-unbundled 1.9.1.1 → 1.9.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/CHANGELOG.md +126 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/bin/vagrant +11 -0
- data/contrib/bash/completion.sh +9 -9
- data/lib/vagrant.rb +4 -2
- data/lib/vagrant/action/builtin/box_add.rb +13 -8
- data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +67 -14
- data/lib/vagrant/action/builtin/provision.rb +10 -5
- data/lib/vagrant/action/general/package_setup_files.rb +51 -0
- data/lib/vagrant/action/general/package_setup_folders.rb +37 -0
- data/lib/vagrant/batch_action.rb +4 -2
- data/lib/vagrant/box_collection.rb +17 -5
- data/lib/vagrant/bundler.rb +110 -12
- data/lib/vagrant/cli.rb +1 -1
- data/lib/vagrant/environment.rb +4 -4
- data/lib/vagrant/errors.rb +32 -0
- data/lib/vagrant/shared_helpers.rb +14 -0
- data/lib/vagrant/ui.rb +3 -3
- data/lib/vagrant/util.rb +7 -1
- data/lib/vagrant/util/command_deprecation.rb +56 -0
- data/lib/vagrant/util/credential_scrubber.rb +29 -0
- data/lib/vagrant/util/guest_inspection.rb +47 -0
- data/lib/vagrant/util/platform.rb +217 -27
- data/lib/vagrant/util/powershell.rb +25 -0
- data/lib/vagrant/util/safe_exec.rb +9 -1
- data/lib/vagrant/util/ssh.rb +1 -1
- data/lib/vagrant/util/subprocess.rb +21 -2
- data/lib/vagrant/util/which.rb +6 -4
- data/plugins/commands/box/command/list.rb +1 -1
- data/plugins/commands/package/command.rb +3 -2
- data/plugins/commands/plugin/action.rb +2 -1
- data/plugins/commands/plugin/action/expunge_plugins.rb +20 -5
- data/plugins/commands/plugin/action/install_gem.rb +0 -8
- data/plugins/commands/plugin/command/expunge.rb +18 -5
- data/plugins/commands/plugin/command/mixin_install_opts.rb +1 -4
- data/plugins/commands/plugin/gem_helper.rb +5 -1
- data/plugins/commands/up/command.rb +1 -1
- data/plugins/commands/validate/command.rb +31 -0
- data/plugins/commands/validate/plugin.rb +17 -0
- data/plugins/communicators/ssh/communicator.rb +50 -25
- data/plugins/communicators/winrm/communicator.rb +8 -54
- data/plugins/communicators/winrm/config.rb +3 -0
- data/plugins/communicators/winrm/helper.rb +1 -1
- data/plugins/communicators/winrm/shell.rb +38 -32
- data/plugins/communicators/winssh/communicator.rb +161 -0
- data/plugins/communicators/winssh/config.rb +30 -0
- data/plugins/communicators/winssh/plugin.rb +21 -0
- data/plugins/guests/arch/cap/change_host_name.rb +0 -3
- data/plugins/guests/arch/cap/configure_networks.rb +1 -1
- data/plugins/guests/atomic/cap/change_host_name.rb +0 -3
- data/plugins/guests/darwin/cap/change_host_name.rb +0 -4
- data/plugins/guests/debian/cap/change_host_name.rb +0 -3
- data/plugins/guests/debian/cap/configure_networks.rb +2 -1
- data/plugins/guests/elementary/guest.rb +10 -0
- data/plugins/guests/elementary/plugin.rb +15 -0
- data/plugins/guests/esxi/cap/public_key.rb +63 -0
- data/plugins/guests/esxi/plugin.rb +11 -0
- data/plugins/guests/freebsd/cap/change_host_name.rb +0 -4
- data/plugins/guests/gentoo/cap/change_host_name.rb +7 -5
- data/plugins/guests/gentoo/cap/configure_networks.rb +57 -21
- data/plugins/guests/linux/cap/mount_smb_shared_folder.rb +20 -53
- data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +10 -58
- data/plugins/guests/linux/cap/network_interfaces.rb +8 -1
- data/plugins/guests/linux/cap/nfs.rb +5 -14
- data/plugins/guests/linux/guest.rb +3 -3
- data/plugins/guests/omnios/cap/change_host_name.rb +0 -3
- data/plugins/guests/openbsd/cap/change_host_name.rb +0 -4
- data/plugins/guests/photon/cap/change_host_name.rb +0 -3
- data/plugins/guests/pld/cap/change_host_name.rb +0 -3
- data/plugins/guests/redhat/cap/change_host_name.rb +2 -9
- data/plugins/guests/redhat/cap/configure_networks.rb +43 -21
- data/plugins/guests/slackware/cap/change_host_name.rb +0 -3
- data/plugins/guests/suse/cap/change_host_name.rb +0 -3
- data/plugins/guests/tinycore/cap/mount_nfs.rb +3 -8
- data/plugins/guests/windows/cap/configure_networks.rb +0 -4
- data/plugins/guests/windows/cap/mount_shared_folder.rb +13 -1
- data/plugins/guests/windows/scripts/mount_volume.ps1.erb +1 -1
- data/plugins/hosts/windows/cap/ps.rb +6 -1
- data/plugins/kernel_v2/config/vm.rb +6 -4
- data/plugins/providers/docker/action.rb +4 -7
- data/plugins/providers/docker/action/build.rb +1 -1
- data/plugins/providers/docker/action/create.rb +3 -0
- data/plugins/providers/docker/config.rb +27 -1
- data/plugins/providers/docker/driver.rb +15 -2
- data/plugins/providers/docker/driver/compose.rb +287 -0
- data/plugins/providers/docker/errors.rb +16 -0
- data/plugins/providers/docker/provider.rb +25 -10
- data/plugins/providers/hyperv/action.rb +33 -8
- data/plugins/providers/hyperv/action/export.rb +39 -0
- data/plugins/providers/hyperv/action/import.rb +23 -4
- data/plugins/providers/hyperv/action/package.rb +16 -0
- data/plugins/providers/hyperv/action/package_metadata_json.rb +34 -0
- data/plugins/providers/hyperv/action/package_setup_files.rb +16 -0
- data/plugins/providers/hyperv/action/package_setup_folders.rb +18 -0
- data/plugins/providers/hyperv/action/package_vagrantfile.rb +34 -0
- data/plugins/providers/hyperv/config.rb +20 -4
- data/plugins/providers/hyperv/driver.rb +12 -0
- data/plugins/providers/hyperv/scripts/export_vm.ps1 +15 -0
- data/plugins/providers/hyperv/scripts/get_network_mac.ps1 +28 -0
- data/plugins/providers/hyperv/scripts/has_vmcx_support.ps1 +11 -0
- data/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 +10 -4
- data/plugins/providers/hyperv/scripts/import_vm_xml.ps1 +9 -3
- data/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 +37 -0
- data/plugins/providers/virtualbox/action/package_setup_files.rb +7 -42
- data/plugins/providers/virtualbox/action/package_setup_folders.rb +6 -26
- data/plugins/providers/virtualbox/driver/base.rb +10 -0
- data/plugins/providers/virtualbox/driver/version_5_0.rb +11 -11
- data/plugins/providers/virtualbox/driver/version_5_1.rb +3 -721
- data/plugins/providers/virtualbox/provider.rb +9 -5
- data/plugins/providers/virtualbox/synced_folder.rb +1 -1
- data/plugins/providers/virtualbox/util/compile_forwarded_ports.rb +3 -1
- data/plugins/provisioners/ansible/cap/guest/arch/ansible_install.rb +2 -2
- data/plugins/provisioners/ansible/cap/guest/debian/ansible_install.rb +8 -8
- data/plugins/provisioners/ansible/cap/guest/fedora/ansible_install.rb +9 -5
- data/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb +1 -1
- data/plugins/provisioners/ansible/cap/guest/pip/pip.rb +5 -3
- data/plugins/provisioners/ansible/cap/guest/redhat/ansible_install.rb +7 -3
- data/plugins/provisioners/ansible/cap/guest/suse/ansible_install.rb +1 -1
- data/plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install.rb +3 -3
- data/plugins/provisioners/ansible/config/guest.rb +7 -1
- data/plugins/provisioners/ansible/provisioner/guest.rb +1 -1
- data/plugins/provisioners/chef/cap/freebsd/chef_install.rb +18 -0
- data/plugins/provisioners/chef/cap/freebsd/chef_installed.rb +22 -0
- data/plugins/provisioners/chef/plugin.rb +10 -0
- data/plugins/provisioners/docker/cap/linux/docker_installed.rb +1 -0
- data/plugins/provisioners/salt/bootstrap-salt.ps1 +4 -4
- data/plugins/provisioners/shell/config.rb +2 -2
- data/plugins/provisioners/shell/provisioner.rb +66 -4
- data/plugins/pushes/atlas/push.rb +6 -0
- data/plugins/pushes/local-exec/config.rb +2 -2
- data/plugins/synced_folders/unix_mount_helpers.rb +105 -0
- data/templates/commands/init/Vagrantfile.erb +6 -0
- data/templates/commands/init/Vagrantfile.min.erb +3 -0
- data/templates/guests/debian/network_dhcp.erb +2 -2
- data/templates/guests/gentoo/network_systemd.erb +16 -0
- data/templates/guests/redhat/network_dhcp.erb +1 -0
- data/templates/guests/redhat/network_static.erb +1 -1
- data/templates/guests/redhat/network_static6.erb +1 -1
- data/templates/locales/en.yml +72 -3
- data/templates/locales/providers_docker.yml +15 -0
- data/test/acceptance/provider-virtualbox/linked_clone_spec.rb +1 -1
- data/test/unit/plugins/commands/init/command_test.rb +7 -0
- data/test/unit/plugins/commands/up/command_test.rb +65 -0
- data/test/unit/plugins/commands/validate/command_test.rb +52 -0
- data/test/unit/plugins/communicators/ssh/communicator_test.rb +58 -2
- data/test/unit/plugins/communicators/winrm/communicator_test.rb +14 -26
- data/test/unit/plugins/communicators/winrm/helper_test.rb +12 -0
- data/test/unit/plugins/communicators/winrm/shell_test.rb +54 -15
- data/test/unit/plugins/communicators/winssh/communicator_test.rb +525 -0
- data/test/unit/plugins/guests/arch/cap/configure_networks_test.rb +5 -0
- data/test/unit/plugins/guests/esxi/cap/public_key_test.rb +48 -0
- data/test/unit/plugins/guests/linux/cap/mount_nfs_test.rb +1 -1
- data/test/unit/plugins/guests/linux/cap/mount_smb_shared_folder.rb +71 -0
- data/test/unit/plugins/guests/linux/cap/mount_virtual_box_shared_folder_test.rb +43 -0
- data/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb +10 -10
- data/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb +132 -12
- data/test/unit/plugins/guests/windows/cap/mount_shared_folder_test.rb +23 -0
- data/test/unit/plugins/providers/docker/driver_compose_test.rb +268 -0
- data/test/unit/plugins/provisioners/ansible/config/guest_test.rb +9 -0
- data/test/unit/plugins/provisioners/ansible/provisioner_test.rb +2 -2
- data/test/unit/plugins/pushes/atlas/push_test.rb +151 -150
- data/test/unit/templates/guests/debian/network_dhcp_test.rb +1 -0
- data/test/unit/templates/guests/gentoo/systemd_network_test.rb +73 -0
- data/test/unit/templates/guests/redhat/network_dhcp_test.rb +18 -0
- data/test/unit/vagrant/action/builtin/box_add_test.rb +27 -0
- data/test/unit/vagrant/action/builtin/handle_forwarded_port_collisions_test.rb +170 -0
- data/test/unit/vagrant/action/builtin/provision_test.rb +208 -0
- data/test/unit/vagrant/box_collection_test.rb +98 -0
- data/test/unit/vagrant/environment_test.rb +17 -0
- data/test/unit/vagrant/shared_helpers_test.rb +12 -0
- data/test/unit/vagrant/util/command_deprecation_test.rb +106 -0
- data/test/unit/vagrant/util/env_test.rb +43 -0
- data/test/unit/vagrant/util/platform_test.rb +8 -0
- data/test/unit/vagrant/util/subprocess_test.rb +61 -0
- data/test/vagrant-spec/Vagrantfile.spec +78 -0
- data/test/vagrant-spec/boxes/.keep +0 -0
- data/test/vagrant-spec/configs/vagrant-spec.config.virtualbox.rb +10 -0
- data/test/vagrant-spec/scripts/centos-run.virtualbox.sh +8 -0
- data/test/vagrant-spec/scripts/centos-setup.virtualbox.sh +14 -0
- data/test/vagrant-spec/scripts/ubuntu-run.virtualbox.sh +8 -0
- data/test/vagrant-spec/scripts/ubuntu-setup.virtualbox.sh +12 -0
- data/vagrant.gemspec +6 -11
- data/version.txt +1 -1
- metadata +1694 -1835
- data/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb +0 -101
@@ -19,7 +19,9 @@ module Vagrant
|
|
19
19
|
def self.execute(path, *args, **opts, &block)
|
20
20
|
command = [
|
21
21
|
"powershell",
|
22
|
+
"-NoLogo",
|
22
23
|
"-NoProfile",
|
24
|
+
"-NonInteractive",
|
23
25
|
"-ExecutionPolicy", "Bypass",
|
24
26
|
"&('#{path}')",
|
25
27
|
args
|
@@ -32,14 +34,37 @@ module Vagrant
|
|
32
34
|
Subprocess.execute(*command, &block)
|
33
35
|
end
|
34
36
|
|
37
|
+
# Execute a powershell command.
|
38
|
+
#
|
39
|
+
# @param [String] command PowerShell command to execute.
|
40
|
+
# @return [Subprocess::Result]
|
41
|
+
def self.execute_cmd(command)
|
42
|
+
c = [
|
43
|
+
"powershell",
|
44
|
+
"-NoLogo",
|
45
|
+
"-NoProfile",
|
46
|
+
"-NonInteractive",
|
47
|
+
"-ExecutionPolicy", "Bypass",
|
48
|
+
"-Command",
|
49
|
+
command
|
50
|
+
].flatten
|
51
|
+
|
52
|
+
r = Subprocess.execute(*c)
|
53
|
+
return nil if r.exit_code != 0
|
54
|
+
return r.stdout.chomp
|
55
|
+
end
|
56
|
+
|
35
57
|
# Returns the version of PowerShell that is installed.
|
36
58
|
#
|
37
59
|
# @return [String]
|
38
60
|
def self.version
|
39
61
|
command = [
|
40
62
|
"powershell",
|
63
|
+
"-NoLogo",
|
41
64
|
"-NoProfile",
|
65
|
+
"-NonInteractive",
|
42
66
|
"-ExecutionPolicy", "Bypass",
|
67
|
+
"-Command",
|
43
68
|
"$PSVersionTable.PSVersion.Major"
|
44
69
|
].flatten
|
45
70
|
|
@@ -40,7 +40,15 @@ module Vagrant
|
|
40
40
|
Process.wait(pid)
|
41
41
|
end
|
42
42
|
else
|
43
|
-
|
43
|
+
if Vagrant::Util::Platform.windows?
|
44
|
+
@@logger.debug("Converting command and arguments to single string for exec")
|
45
|
+
@@logger.debug("Command: `#{command.inspect}` Args: `#{args.inspect}`")
|
46
|
+
full_command = "#{command} #{args.join(" ")}"
|
47
|
+
@@logger.debug("Converted command: #{full_command}")
|
48
|
+
Kernel.exec(full_command)
|
49
|
+
else
|
50
|
+
Kernel.exec(command, *args)
|
51
|
+
end
|
44
52
|
end
|
45
53
|
rescue *rescue_from
|
46
54
|
# We retried already, raise the issue and be done
|
data/lib/vagrant/util/ssh.rb
CHANGED
@@ -28,7 +28,7 @@ module Vagrant
|
|
28
28
|
def self.check_key_permissions(key_path)
|
29
29
|
# Don't do anything if we're on Windows, since Windows doesn't worry
|
30
30
|
# about key permissions.
|
31
|
-
return if Platform.windows?
|
31
|
+
return if Platform.windows? || Platform.wsl_windows_access_bypass?(key_path)
|
32
32
|
|
33
33
|
LOGGER.debug("Checking key permissions: #{key_path}")
|
34
34
|
stat = key_path.stat
|
@@ -25,7 +25,6 @@ module Vagrant
|
|
25
25
|
def initialize(*command)
|
26
26
|
@options = command.last.is_a?(Hash) ? command.pop : {}
|
27
27
|
@command = command.dup
|
28
|
-
@command = @command.map { |s| s.encode(Encoding.default_external) }
|
29
28
|
@command[0] = Which.which(@command[0]) if !File.file?(@command[0])
|
30
29
|
if !@command[0]
|
31
30
|
raise Errors::CommandUnavailableWindows, file: command[0] if Platform.windows?
|
@@ -35,6 +34,26 @@ module Vagrant
|
|
35
34
|
@logger = Log4r::Logger.new("vagrant::util::subprocess")
|
36
35
|
end
|
37
36
|
|
37
|
+
# @return [TrueClass, FalseClass] subprocess is currently running
|
38
|
+
def running?
|
39
|
+
!!(@process && @process.alive?)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Stop the subprocess if running
|
43
|
+
#
|
44
|
+
# @return [TrueClass] FalseClass] true if process was running and stopped
|
45
|
+
def stop
|
46
|
+
if @process && @process.alive?
|
47
|
+
@process.stop
|
48
|
+
true
|
49
|
+
else
|
50
|
+
false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Start the process
|
55
|
+
#
|
56
|
+
# @return [Result]
|
38
57
|
def execute
|
39
58
|
# Get the timeout, if we have one
|
40
59
|
timeout = @options[:timeout]
|
@@ -62,7 +81,7 @@ module Vagrant
|
|
62
81
|
|
63
82
|
# Build the ChildProcess
|
64
83
|
@logger.info("Starting process: #{@command.inspect}")
|
65
|
-
process = ChildProcess.build(*@command)
|
84
|
+
@process = process = ChildProcess.build(*@command)
|
66
85
|
|
67
86
|
# Create the pipes so we can read the output in real time as
|
68
87
|
# we execute the command.
|
data/lib/vagrant/util/which.rb
CHANGED
@@ -29,10 +29,12 @@ module Vagrant
|
|
29
29
|
exts = ENV['PATHEXT'].split(';')
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
SilenceWarnings.silence! do
|
33
|
+
ENV['PATH'].encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').split(File::PATH_SEPARATOR).each do |path|
|
34
|
+
exts.each do |ext|
|
35
|
+
exe = "#{path}#{File::SEPARATOR}#{cmd}#{ext}"
|
36
|
+
return exe if File.executable? exe
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'optparse'
|
2
|
+
require 'securerandom'
|
2
3
|
|
3
4
|
module VagrantPlugins
|
4
5
|
module CommandPackage
|
@@ -16,7 +17,7 @@ module VagrantPlugins
|
|
16
17
|
o.separator "Options:"
|
17
18
|
o.separator ""
|
18
19
|
|
19
|
-
o.on("--base NAME", "Name of a VM in
|
20
|
+
o.on("--base NAME", "Name of a VM in VirtualBox to package as a base box (VirtualBox Only)") do |b|
|
20
21
|
options[:base] = b
|
21
22
|
end
|
22
23
|
|
@@ -24,7 +25,7 @@ module VagrantPlugins
|
|
24
25
|
options[:output] = output
|
25
26
|
end
|
26
27
|
|
27
|
-
o.on("--include FILE
|
28
|
+
o.on("--include FILE,FILE..", Array, "Comma separated additional files to package with the box") do |i|
|
28
29
|
options[:include] = i
|
29
30
|
end
|
30
31
|
|
@@ -5,13 +5,14 @@ require "vagrant/action/builder"
|
|
5
5
|
module VagrantPlugins
|
6
6
|
module CommandPlugin
|
7
7
|
module Action
|
8
|
-
# This middleware sequence will
|
8
|
+
# This middleware sequence will remove all plugins.
|
9
9
|
def self.action_expunge
|
10
10
|
Vagrant::Action::Builder.new.tap do |b|
|
11
11
|
b.use ExpungePlugins
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
# This middleware sequence will install a plugin.
|
15
16
|
def self.action_install
|
16
17
|
Vagrant::Action::Builder.new.tap do |b|
|
17
18
|
b.use InstallGem
|
@@ -17,11 +17,26 @@ module VagrantPlugins
|
|
17
17
|
|
18
18
|
def call(env)
|
19
19
|
if !env[:force]
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
|
21
|
+
result = nil
|
22
|
+
attempts = 0
|
23
|
+
while attempts < 5 && result.nil?
|
24
|
+
attempts += 1
|
25
|
+
result = env[:ui].ask(
|
26
|
+
I18n.t("vagrant.commands.plugin.expunge_confirm") +
|
27
|
+
" [N]: "
|
28
|
+
)
|
29
|
+
result = result.to_s.downcase.strip
|
30
|
+
result = "n" if result.empty?
|
31
|
+
if !["y", "yes", "n", "no"].include?(result)
|
32
|
+
result = nil
|
33
|
+
env[:ui].error("Please answer Y or N")
|
34
|
+
else
|
35
|
+
result = result[0,1]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if result != 'y'
|
25
40
|
abort_action = true
|
26
41
|
end
|
27
42
|
end
|
@@ -19,14 +19,6 @@ module VagrantPlugins
|
|
19
19
|
sources = env[:plugin_sources]
|
20
20
|
version = env[:plugin_version]
|
21
21
|
|
22
|
-
# If we're on Windows and the user data path has a space in it,
|
23
|
-
# then things won't work because of a Ruby bug.
|
24
|
-
if Vagrant::Util::Platform.windows?
|
25
|
-
if Vagrant.user_data_path.to_s.include?(" ")
|
26
|
-
raise Vagrant::Errors::PluginInstallSpace
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
22
|
# Install the gem
|
31
23
|
plugin_name_label = plugin_name
|
32
24
|
plugin_name_label += " --version '#{version}'" if version
|
@@ -29,11 +29,24 @@ module VagrantPlugins
|
|
29
29
|
plugins = Vagrant::Plugin::Manager.instance.installed_plugins
|
30
30
|
|
31
31
|
if !options[:reinstall] && !options[:force] && !plugins.empty?
|
32
|
-
result =
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
result = nil
|
33
|
+
attempts = 0
|
34
|
+
while attempts < 5 && result.nil?
|
35
|
+
attempts += 1
|
36
|
+
result = @env.ui.ask(
|
37
|
+
I18n.t("vagrant.commands.plugin.expunge_request_reinstall") +
|
38
|
+
" [N]: "
|
39
|
+
)
|
40
|
+
result = result.to_s.downcase.strip
|
41
|
+
result = "n" if result.empty?
|
42
|
+
if !["y", "yes", "n", "no"].include?(result)
|
43
|
+
result = nil
|
44
|
+
@env.ui.error("Please answer Y or N")
|
45
|
+
else
|
46
|
+
result = result[0,1]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
options[:reinstall] = result == "y"
|
37
50
|
end
|
38
51
|
|
39
52
|
# Remove all installed user plugins
|
@@ -3,10 +3,7 @@ module VagrantPlugins
|
|
3
3
|
module Command
|
4
4
|
module MixinInstallOpts
|
5
5
|
def build_install_opts(o, options)
|
6
|
-
options[:plugin_sources] =
|
7
|
-
"https://rubygems.org",
|
8
|
-
"https://gems.hashicorp.com",
|
9
|
-
]
|
6
|
+
options[:plugin_sources] = Vagrant::Bundler::DEFAULT_GEM_SOURCES.dup
|
10
7
|
|
11
8
|
o.on("--entry-point NAME", String,
|
12
9
|
"The name of the entry point file for loading the plugin.") do |entry_point|
|
@@ -43,7 +43,11 @@ module VagrantPlugins
|
|
43
43
|
# Clear the sources so that installation uses custom sources
|
44
44
|
old_sources = Gem.sources
|
45
45
|
Gem.sources = Gem.default_sources
|
46
|
-
|
46
|
+
Vagrant::Bundler::DEFAULT_GEM_SOURCES.each do |source|
|
47
|
+
if !Gem.sources.include?(source)
|
48
|
+
Gem.sources << source
|
49
|
+
end
|
50
|
+
end
|
47
51
|
|
48
52
|
# Use a silent UI so that we have no output
|
49
53
|
Gem::DefaultUserInteraction.use_ui(Gem::SilentUI.new) do
|
@@ -128,7 +128,7 @@ module VagrantPlugins
|
|
128
128
|
# First create a set of all the providers we need to check for.
|
129
129
|
# Most likely this will be a set of one.
|
130
130
|
providers = Set.new
|
131
|
-
with_target_vms(names) do |machine|
|
131
|
+
with_target_vms(names, provider: provider) do |machine|
|
132
132
|
# Check if we have this machine in the index
|
133
133
|
entry = @env.machine_index.get(machine.name.to_s)
|
134
134
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module CommandValidate
|
5
|
+
class Command < Vagrant.plugin("2", :command)
|
6
|
+
def self.synopsis
|
7
|
+
"validates the Vagrantfile"
|
8
|
+
end
|
9
|
+
|
10
|
+
def execute
|
11
|
+
opts = OptionParser.new do |o|
|
12
|
+
o.banner = "Usage: vagrant validate"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Parse the options
|
16
|
+
argv = parse_options(opts)
|
17
|
+
return if !argv
|
18
|
+
|
19
|
+
# Validate the configuration
|
20
|
+
@env.machine(@env.machine_names.first, @env.default_provider).action_raw(
|
21
|
+
:config_validate,
|
22
|
+
Vagrant::Action::Builtin::ConfigValidate)
|
23
|
+
|
24
|
+
@env.ui.info(I18n.t("vagrant.commands.validate.success"))
|
25
|
+
|
26
|
+
# Success, exit status 0
|
27
|
+
0
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module CommandValidate
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
6
|
+
name "validate command"
|
7
|
+
description <<-DESC
|
8
|
+
The `validate` command validates the Vagrantfile.
|
9
|
+
DESC
|
10
|
+
|
11
|
+
command("validate") do
|
12
|
+
require File.expand_path("../command", __FILE__)
|
13
|
+
Command
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -25,6 +25,20 @@ module VagrantPlugins
|
|
25
25
|
PTY_DELIM_END = "bccbb768c119429488cfd109aacea6b5-pty"
|
26
26
|
# Marker for start of regular command output
|
27
27
|
CMD_GARBAGE_MARKER = "41e57d38-b4f7-4e46-9c38-13873d338b86-vagrant-ssh"
|
28
|
+
# These are the exceptions that we retry because they represent
|
29
|
+
# errors that are generally fixed from a retry and don't
|
30
|
+
# necessarily represent immediate failure cases.
|
31
|
+
SSH_RETRY_EXCEPTIONS = [
|
32
|
+
Errno::EACCES,
|
33
|
+
Errno::EADDRINUSE,
|
34
|
+
Errno::ECONNABORTED,
|
35
|
+
Errno::ECONNREFUSED,
|
36
|
+
Errno::ECONNRESET,
|
37
|
+
Errno::ENETUNREACH,
|
38
|
+
Errno::EHOSTUNREACH,
|
39
|
+
Net::SSH::Disconnect,
|
40
|
+
Timeout::Error
|
41
|
+
]
|
28
42
|
|
29
43
|
include Vagrant::Util::ANSIEscapeCodeRemover
|
30
44
|
include Vagrant::Util::Retryable
|
@@ -81,6 +95,8 @@ module VagrantPlugins
|
|
81
95
|
message = "Connection refused."
|
82
96
|
rescue Vagrant::Errors::SSHConnectionReset
|
83
97
|
message = "Connection reset."
|
98
|
+
rescue Vagrant::Errors::SSHConnectionAborted
|
99
|
+
message = "Connection aborted."
|
84
100
|
rescue Vagrant::Errors::SSHHostDown
|
85
101
|
message = "Host appears down."
|
86
102
|
rescue Vagrant::Errors::SSHNoRoute
|
@@ -143,7 +159,7 @@ module VagrantPlugins
|
|
143
159
|
# If we're already attempting to switch out the SSH key, then
|
144
160
|
# just return that we're ready (for Machine#guest).
|
145
161
|
@lock.synchronize do
|
146
|
-
return true if @inserted_key ||
|
162
|
+
return true if @inserted_key || !machine_config_ssh.insert_key
|
147
163
|
@inserted_key = true
|
148
164
|
end
|
149
165
|
|
@@ -350,24 +366,10 @@ module VagrantPlugins
|
|
350
366
|
# Connect to SSH, giving it a few tries
|
351
367
|
connection = nil
|
352
368
|
begin
|
353
|
-
# These are the exceptions that we retry because they represent
|
354
|
-
# errors that are generally fixed from a retry and don't
|
355
|
-
# necessarily represent immediate failure cases.
|
356
|
-
exceptions = [
|
357
|
-
Errno::EACCES,
|
358
|
-
Errno::EADDRINUSE,
|
359
|
-
Errno::ECONNREFUSED,
|
360
|
-
Errno::ECONNRESET,
|
361
|
-
Errno::ENETUNREACH,
|
362
|
-
Errno::EHOSTUNREACH,
|
363
|
-
Net::SSH::Disconnect,
|
364
|
-
Timeout::Error
|
365
|
-
]
|
366
|
-
|
367
369
|
timeout = 60
|
368
370
|
|
369
371
|
@logger.info("Attempting SSH connection...")
|
370
|
-
connection = retryable(tries: opts[:retries], on:
|
372
|
+
connection = retryable(tries: opts[:retries], on: SSH_RETRY_EXCEPTIONS) do
|
371
373
|
Timeout.timeout(timeout) do
|
372
374
|
begin
|
373
375
|
# This logger will get the Net-SSH log data for us.
|
@@ -426,6 +428,10 @@ module VagrantPlugins
|
|
426
428
|
# This is raised if we failed to connect the max number of times
|
427
429
|
# due to an ECONNRESET.
|
428
430
|
raise Vagrant::Errors::SSHConnectionReset
|
431
|
+
rescue Errno::ECONNABORTED
|
432
|
+
# This is raised if we failed to connect the max number of times
|
433
|
+
# due to an ECONNABORTED
|
434
|
+
raise Vagrant::Errors::SSHConnectionAborted
|
429
435
|
rescue Errno::EHOSTDOWN
|
430
436
|
# This is raised if we get an ICMP DestinationUnknown error.
|
431
437
|
raise Vagrant::Errors::SSHHostDown
|
@@ -458,9 +464,9 @@ module VagrantPlugins
|
|
458
464
|
# Determine the shell to execute. Prefer the explicitly passed in shell
|
459
465
|
# over the default configured shell. If we are using `sudo` then we
|
460
466
|
# need to wrap the shell in a `sudo` call.
|
461
|
-
cmd =
|
467
|
+
cmd = machine_config_ssh.shell
|
462
468
|
cmd = shell if shell
|
463
|
-
cmd =
|
469
|
+
cmd = machine_config_ssh.sudo_command.gsub("%c", cmd) if sudo
|
464
470
|
cmd
|
465
471
|
end
|
466
472
|
|
@@ -482,7 +488,7 @@ module VagrantPlugins
|
|
482
488
|
|
483
489
|
# Open the channel so we can execute or command
|
484
490
|
channel = connection.open_channel do |ch|
|
485
|
-
if
|
491
|
+
if machine_config_ssh.pty
|
486
492
|
ch.request_pty do |ch2, success|
|
487
493
|
pty = success && command != ""
|
488
494
|
|
@@ -496,6 +502,8 @@ module VagrantPlugins
|
|
496
502
|
|
497
503
|
marker_found = false
|
498
504
|
data_buffer = ''
|
505
|
+
stderr_marker_found = false
|
506
|
+
stderr_data_buffer = ''
|
499
507
|
|
500
508
|
ch.exec(shell_cmd(opts)) do |ch2, _|
|
501
509
|
# Setup the channel callbacks so we can get data and exit status
|
@@ -512,12 +520,12 @@ module VagrantPlugins
|
|
512
520
|
if marker_index
|
513
521
|
marker_found = true
|
514
522
|
data_buffer.slice!(0, marker_index + CMD_GARBAGE_MARKER.size)
|
515
|
-
data.replace
|
523
|
+
data.replace(data_buffer)
|
516
524
|
data_buffer = nil
|
517
525
|
end
|
518
526
|
end
|
519
527
|
|
520
|
-
if block_given? && marker_found
|
528
|
+
if block_given? && marker_found && !data.empty?
|
521
529
|
yield :stdout, data
|
522
530
|
end
|
523
531
|
end
|
@@ -527,7 +535,20 @@ module VagrantPlugins
|
|
527
535
|
# Filter out the clear screen command
|
528
536
|
data = remove_ansi_escape_codes(data)
|
529
537
|
@logger.debug("stderr: #{data}")
|
530
|
-
|
538
|
+
if !stderr_marker_found
|
539
|
+
stderr_data_buffer << data
|
540
|
+
marker_index = stderr_data_buffer.index(CMD_GARBAGE_MARKER)
|
541
|
+
if marker_index
|
542
|
+
marker_found = true
|
543
|
+
stderr_data_buffer.slice!(0, marker_index + CMD_GARBAGE_MARKER.size)
|
544
|
+
data.replace(stderr_data_buffer)
|
545
|
+
data_buffer = nil
|
546
|
+
end
|
547
|
+
end
|
548
|
+
|
549
|
+
if block_given? && marker_found && !data.empty?
|
550
|
+
yield :stderr, data
|
551
|
+
end
|
531
552
|
end
|
532
553
|
|
533
554
|
ch2.on_request("exit-status") do |ch3, data|
|
@@ -583,7 +604,7 @@ module VagrantPlugins
|
|
583
604
|
data = data.force_encoding('ASCII-8BIT')
|
584
605
|
ch2.send_data data
|
585
606
|
else
|
586
|
-
ch2.send_data "printf '#{CMD_GARBAGE_MARKER}'\n#{command}\n".force_encoding('ASCII-8BIT')
|
607
|
+
ch2.send_data "printf '#{CMD_GARBAGE_MARKER}'\n(>&2 printf '#{CMD_GARBAGE_MARKER}')\n#{command}\n".force_encoding('ASCII-8BIT')
|
587
608
|
# Remember to exit or this channel will hang open
|
588
609
|
ch2.send_data "exit\n"
|
589
610
|
end
|
@@ -596,7 +617,7 @@ module VagrantPlugins
|
|
596
617
|
begin
|
597
618
|
keep_alive = nil
|
598
619
|
|
599
|
-
if
|
620
|
+
if machine_config_ssh.keep_alive
|
600
621
|
# Begin sending keep-alive packets while we wait for the script
|
601
622
|
# to complete. This avoids connections closing on long-running
|
602
623
|
# scripts.
|
@@ -672,9 +693,13 @@ module VagrantPlugins
|
|
672
693
|
end
|
673
694
|
|
674
695
|
def generate_environment_export(env_key, env_value)
|
675
|
-
template =
|
696
|
+
template = machine_config_ssh.export_command_template
|
676
697
|
template.sub("%ENV_KEY%", env_key).sub("%ENV_VALUE%", env_value) + "\n"
|
677
698
|
end
|
699
|
+
|
700
|
+
def machine_config_ssh
|
701
|
+
@machine.config.ssh
|
702
|
+
end
|
678
703
|
end
|
679
704
|
end
|
680
705
|
end
|