vagrant-unbundled 2.2.6.0 → 2.2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hashibot.hcl +14 -0
- data/CHANGELOG.md +93 -2
- data/README.md +1 -3
- data/bin/vagrant +23 -0
- data/contrib/bash/completion.sh +13 -1
- data/lib/vagrant.rb +25 -0
- data/lib/vagrant/action.rb +5 -0
- data/lib/vagrant/action/builder.rb +145 -24
- data/lib/vagrant/action/builtin/box_add.rb +11 -4
- data/lib/vagrant/action/builtin/box_check_outdated.rb +12 -15
- data/lib/vagrant/action/builtin/cleanup_disks.rb +56 -0
- data/lib/vagrant/action/builtin/delayed.rb +26 -0
- data/lib/vagrant/action/builtin/disk.rb +52 -0
- data/lib/vagrant/action/builtin/handle_box.rb +2 -0
- data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +28 -9
- data/lib/vagrant/action/builtin/mixin_provisioners.rb +19 -1
- data/lib/vagrant/action/builtin/ssh_run.rb +21 -3
- data/lib/vagrant/action/builtin/trigger.rb +36 -0
- data/lib/vagrant/action/hook.rb +20 -2
- data/lib/vagrant/action/runner.rb +11 -26
- data/lib/vagrant/action/warden.rb +4 -18
- data/lib/vagrant/box_metadata.rb +17 -3
- data/lib/vagrant/bundler.rb +260 -53
- data/lib/vagrant/cli.rb +4 -2
- data/lib/vagrant/errors.rb +24 -0
- data/lib/vagrant/machine.rb +9 -6
- data/lib/vagrant/plugin/manager.rb +25 -14
- data/lib/vagrant/plugin/v2/command.rb +1 -1
- data/lib/vagrant/plugin/v2/manager.rb +53 -0
- data/lib/vagrant/plugin/v2/plugin.rb +1 -0
- data/lib/vagrant/plugin/v2/trigger.rb +64 -26
- data/lib/vagrant/shared_helpers.rb +28 -0
- data/lib/vagrant/ui.rb +50 -4
- data/lib/vagrant/util.rb +1 -0
- data/lib/vagrant/util/curl_helper.rb +8 -5
- data/lib/vagrant/util/downloader.rb +5 -1
- data/lib/vagrant/util/file_checksum.rb +6 -2
- data/lib/vagrant/util/guest_inspection.rb +9 -1
- data/lib/vagrant/util/io.rb +7 -27
- data/lib/vagrant/util/is_port_open.rb +1 -2
- data/lib/vagrant/util/map_command_options.rb +33 -0
- data/lib/vagrant/util/numeric.rb +69 -0
- data/lib/vagrant/util/platform.rb +8 -1
- data/plugins/commands/box/command/outdated.rb +14 -2
- data/plugins/commands/cloud/locales/en.yml +1 -1
- data/plugins/commands/cloud/publish.rb +1 -1
- data/plugins/commands/snapshot/command/save.rb +13 -8
- data/plugins/commands/ssh_config/command.rb +1 -1
- data/plugins/communicators/ssh/communicator.rb +18 -23
- data/plugins/communicators/winrm/config.rb +1 -1
- data/plugins/communicators/winrm/shell.rb +1 -1
- data/plugins/communicators/winssh/communicator.rb +126 -38
- data/plugins/communicators/winssh/config.rb +3 -7
- data/plugins/guests/alpine/cap/rsync.rb +1 -1
- data/plugins/guests/alpine/plugin.rb +16 -0
- data/plugins/guests/centos/cap/flavor.rb +24 -0
- data/plugins/guests/centos/guest.rb +9 -0
- data/plugins/guests/centos/plugin.rb +20 -0
- data/plugins/guests/darwin/cap/mount_vmware_shared_folder.rb +99 -13
- data/plugins/guests/darwin/plugin.rb +5 -0
- data/plugins/guests/debian/cap/configure_networks.rb +14 -6
- data/plugins/guests/linux/cap/halt.rb +9 -1
- data/plugins/guests/linux/cap/mount_smb_shared_folder.rb +16 -0
- data/plugins/guests/linux/cap/reboot.rb +48 -0
- data/plugins/guests/linux/plugin.rb +10 -0
- data/plugins/guests/redhat/cap/flavor.rb +3 -1
- data/plugins/guests/redhat/cap/nfs_client.rb +2 -2
- data/plugins/guests/redhat/cap/smb.rb +20 -0
- data/plugins/guests/redhat/plugin.rb +5 -0
- data/plugins/guests/suse/cap/change_host_name.rb +2 -2
- data/plugins/guests/windows/cap/public_key.rb +3 -3
- data/plugins/guests/windows/cap/reboot.rb +2 -1
- data/plugins/hosts/darwin/cap/nfs.rb +11 -0
- data/plugins/hosts/darwin/plugin.rb +5 -0
- data/plugins/hosts/linux/cap/nfs.rb +21 -2
- data/plugins/kernel_v2/config/disk.rb +199 -0
- data/plugins/kernel_v2/config/ssh_connect.rb +24 -0
- data/plugins/kernel_v2/config/vm.rb +109 -4
- data/plugins/kernel_v2/config/vm_provisioner.rb +4 -1
- data/plugins/kernel_v2/config/vm_trigger.rb +2 -5
- data/plugins/providers/docker/driver.rb +38 -10
- data/plugins/providers/docker/errors.rb +4 -0
- data/plugins/providers/docker/executor/local.rb +7 -1
- data/plugins/providers/hyperv/action/export.rb +4 -2
- data/plugins/providers/hyperv/driver.rb +10 -9
- data/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 +3 -3
- data/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 +6 -6
- data/plugins/providers/virtualbox/action.rb +2 -0
- data/plugins/providers/virtualbox/action/clean_machine_folder.rb +10 -1
- data/plugins/providers/virtualbox/action/export.rb +4 -2
- data/plugins/providers/virtualbox/action/import.rb +8 -4
- data/plugins/providers/virtualbox/action/prepare_clone_snapshot.rb +4 -2
- data/plugins/providers/virtualbox/action/snapshot_delete.rb +4 -2
- data/plugins/providers/virtualbox/action/snapshot_restore.rb +4 -2
- data/plugins/providers/virtualbox/cap/cleanup_disks.rb +54 -0
- data/plugins/providers/virtualbox/cap/configure_disks.rb +287 -0
- data/plugins/providers/virtualbox/cap/validate_disk_ext.rb +27 -0
- data/plugins/providers/virtualbox/driver/base.rb +15 -0
- data/plugins/providers/virtualbox/driver/meta.rb +14 -2
- data/plugins/providers/virtualbox/driver/version_5_0.rb +142 -2
- data/plugins/providers/virtualbox/driver/version_6_1.rb +39 -0
- data/plugins/providers/virtualbox/plugin.rb +21 -0
- data/plugins/provisioners/ansible/cap/guest/alpine/ansible_install.rb +44 -0
- data/plugins/provisioners/ansible/cap/guest/arch/ansible_install.rb +20 -3
- data/plugins/provisioners/ansible/cap/guest/debian/ansible_install.rb +4 -5
- data/plugins/provisioners/ansible/cap/guest/fedora/ansible_install.rb +2 -2
- data/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb +2 -2
- data/plugins/provisioners/ansible/cap/guest/pip/pip.rb +8 -4
- data/plugins/provisioners/ansible/cap/guest/redhat/ansible_install.rb +2 -2
- data/plugins/provisioners/ansible/cap/guest/suse/ansible_install.rb +2 -1
- data/plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install.rb +3 -3
- data/plugins/provisioners/ansible/plugin.rb +5 -0
- data/plugins/provisioners/ansible/provisioner/base.rb +1 -1
- data/plugins/provisioners/container/client.rb +203 -0
- data/plugins/provisioners/container/config.rb +83 -0
- data/plugins/provisioners/container/installer.rb +13 -0
- data/plugins/provisioners/container/plugin.rb +23 -0
- data/plugins/provisioners/container/provisioner.rb +28 -0
- data/plugins/provisioners/docker/cap/{redhat → centos}/docker_install.rb +10 -7
- data/plugins/provisioners/docker/cap/centos/docker_start_service.rb +24 -0
- data/plugins/provisioners/docker/client.rb +4 -175
- data/plugins/provisioners/docker/config.rb +2 -72
- data/plugins/provisioners/docker/installer.rb +3 -5
- data/plugins/provisioners/docker/plugin.rb +6 -6
- data/plugins/provisioners/docker/provisioner.rb +4 -10
- data/plugins/provisioners/podman/cap/centos/podman_install.rb +35 -0
- data/plugins/provisioners/podman/cap/linux/podman_installed.rb +13 -0
- data/plugins/provisioners/podman/cap/redhat/podman_install.rb +26 -0
- data/plugins/provisioners/podman/client.rb +12 -0
- data/plugins/provisioners/podman/config.rb +28 -0
- data/plugins/provisioners/podman/installer.rb +33 -0
- data/plugins/provisioners/podman/plugin.rb +38 -0
- data/plugins/provisioners/podman/provisioner.rb +52 -0
- data/plugins/provisioners/salt/provisioner.rb +4 -0
- data/plugins/provisioners/shell/config.rb +1 -6
- data/plugins/provisioners/shell/provisioner.rb +54 -25
- data/plugins/synced_folders/smb/synced_folder.rb +1 -1
- data/templates/commands/init/Vagrantfile.erb +1 -1
- data/templates/locales/en.yml +123 -4
- data/templates/locales/providers_docker.yml +2 -0
- data/templates/nfs/exports_darwin.erb +7 -0
- data/vagrant.gemspec +8 -9
- data/version.txt +1 -1
- metadata +3731 -3663
- data/lib/vagrant/action/builtin/after_trigger.rb +0 -31
- data/lib/vagrant/action/builtin/before_trigger.rb +0 -28
- data/plugins/provisioners/docker/cap/redhat/docker_start_service.rb +0 -16
data/lib/vagrant/util.rb
CHANGED
@@ -7,6 +7,7 @@ module Vagrant
|
|
7
7
|
autoload :CredentialScrubber, 'vagrant/util/credential_scrubber'
|
8
8
|
autoload :DeepMerge, 'vagrant/util/deep_merge'
|
9
9
|
autoload :Env, 'vagrant/util/env'
|
10
|
+
autoload :Experimental, 'vagrant/util/experimental'
|
10
11
|
autoload :HashWithIndifferentAccess, 'vagrant/util/hash_with_indifferent_access'
|
11
12
|
autoload :GuestInspection, 'vagrant/util/guest_inspection'
|
12
13
|
autoload :LoggingFormatter, 'vagrant/util/logging_formatter'
|
@@ -37,8 +37,10 @@ module Vagrant
|
|
37
37
|
source_host = source_uri.host.to_s.split(".", 2).last
|
38
38
|
location_host = location_uri.host.to_s.split(".", 2).last
|
39
39
|
if !redirect_notify && location_host != source_host && !SILENCED_HOSTS.include?(location_host)
|
40
|
-
ui.
|
41
|
-
|
40
|
+
ui.rewriting do |ui|
|
41
|
+
ui.clear_line
|
42
|
+
ui.detail "Download redirected to host: #{location_uri.host}"
|
43
|
+
end
|
42
44
|
end
|
43
45
|
redirect_notify = true
|
44
46
|
end
|
@@ -82,10 +84,11 @@ module Vagrant
|
|
82
84
|
# 9 - Time spent
|
83
85
|
# 10 - Time left
|
84
86
|
# 11 - Current speed
|
85
|
-
|
86
87
|
output = "Progress: #{columns[0]}% (Rate: #{columns[11]}/s, Estimated time remaining: #{columns[10]})"
|
87
|
-
ui.
|
88
|
-
|
88
|
+
ui.rewriting do |ui|
|
89
|
+
ui.clear_line
|
90
|
+
ui.detail(output, new_line: false)
|
91
|
+
end
|
89
92
|
end
|
90
93
|
end
|
91
94
|
|
@@ -9,6 +9,7 @@ require "vagrant/util/platform"
|
|
9
9
|
require "vagrant/util/subprocess"
|
10
10
|
require "vagrant/util/curl_helper"
|
11
11
|
require "vagrant/util/file_checksum"
|
12
|
+
require "vagrant/util/map_command_options"
|
12
13
|
|
13
14
|
module Vagrant
|
14
15
|
module Util
|
@@ -69,6 +70,7 @@ module Vagrant
|
|
69
70
|
:sha384 => options[:sha384],
|
70
71
|
:sha512 => options[:sha512]
|
71
72
|
}.compact
|
73
|
+
@extra_download_options = options[:box_extra_download_options] || []
|
72
74
|
end
|
73
75
|
|
74
76
|
# This executes the actual download, downloading the source file
|
@@ -183,6 +185,7 @@ module Vagrant
|
|
183
185
|
|
184
186
|
def execute_curl(options, subprocess_options, &data_proc)
|
185
187
|
options = options.dup
|
188
|
+
options.unshift("-q")
|
186
189
|
options << subprocess_options
|
187
190
|
|
188
191
|
# Create the callback that is called if we are interrupted
|
@@ -230,7 +233,6 @@ module Vagrant
|
|
230
233
|
def options
|
231
234
|
# Build the list of parameters to execute with cURL
|
232
235
|
options = [
|
233
|
-
"-q",
|
234
236
|
"--fail",
|
235
237
|
"--location",
|
236
238
|
"--max-redirs", "10", "--verbose",
|
@@ -245,6 +247,8 @@ module Vagrant
|
|
245
247
|
options << "-u" << @auth if @auth
|
246
248
|
options << "--location-trusted" if @location_trusted
|
247
249
|
|
250
|
+
options.concat(@extra_download_options)
|
251
|
+
|
248
252
|
if @headers
|
249
253
|
Array(@headers).each do |header|
|
250
254
|
options << "-H" << header
|
@@ -2,6 +2,9 @@
|
|
2
2
|
# passed into FileChecksum. Note that this isn't strictly enforced at
|
3
3
|
# the moment, and this class isn't directly used. It is merely here for
|
4
4
|
# documentation of structure of the class.
|
5
|
+
|
6
|
+
require "vagrant/errors"
|
7
|
+
|
5
8
|
class DigestClass
|
6
9
|
def update(string); end
|
7
10
|
def hexdigest; end
|
@@ -62,8 +65,9 @@ class FileChecksum
|
|
62
65
|
def load_digest(type)
|
63
66
|
digest = CHECKSUM_MAP[type.to_s.to_sym]
|
64
67
|
if digest.nil?
|
65
|
-
raise Errors::BoxChecksumInvalidType,
|
66
|
-
type: type.to_s
|
68
|
+
raise Vagrant::Errors::BoxChecksumInvalidType,
|
69
|
+
type: type.to_s,
|
70
|
+
types: CHECKSUM_MAP.keys.join(', ')
|
67
71
|
end
|
68
72
|
digest
|
69
73
|
end
|
@@ -12,7 +12,7 @@ module Vagrant
|
|
12
12
|
#
|
13
13
|
# @return [Boolean]
|
14
14
|
def systemd?(comm)
|
15
|
-
comm.test("ps -o comm= 1 | grep systemd")
|
15
|
+
comm.test("ps -o comm= 1 | grep systemd", sudo: true)
|
16
16
|
end
|
17
17
|
|
18
18
|
# systemd-networkd.service is in use
|
@@ -73,6 +73,14 @@ module Vagrant
|
|
73
73
|
comm.test("command -v netplan")
|
74
74
|
end
|
75
75
|
|
76
|
+
# is networkd isntalled
|
77
|
+
#
|
78
|
+
# @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
|
79
|
+
# @return [Boolean]
|
80
|
+
def networkd?(comm)
|
81
|
+
comm.test("command -v networkd")
|
82
|
+
end
|
83
|
+
|
76
84
|
## nmcli helpers
|
77
85
|
|
78
86
|
# nmcli is installed
|
data/lib/vagrant/util/io.rb
CHANGED
@@ -29,42 +29,22 @@ module Vagrant
|
|
29
29
|
break if !results || results[0].empty?
|
30
30
|
|
31
31
|
# Read!
|
32
|
-
data << io.readpartial(READ_CHUNK_SIZE).encode(
|
32
|
+
data << io.readpartial(READ_CHUNK_SIZE).encode(
|
33
|
+
"UTF-8", Encoding.default_external,
|
34
|
+
invalid: :replace,
|
35
|
+
undef: :replace
|
36
|
+
)
|
33
37
|
else
|
34
38
|
# Do a simple non-blocking read on the IO object
|
35
39
|
data << io.read_nonblock(READ_CHUNK_SIZE)
|
36
40
|
end
|
37
|
-
rescue
|
38
|
-
|
39
|
-
# since we use some Ruby 1.9 specific exceptions.
|
40
|
-
|
41
|
-
breakable = false
|
42
|
-
if e.is_a?(EOFError)
|
43
|
-
# An `EOFError` means this IO object is done!
|
44
|
-
breakable = true
|
45
|
-
elsif defined?(::IO::WaitReadable) && e.is_a?(::IO::WaitReadable)
|
46
|
-
# IO::WaitReadable is only available on Ruby 1.9+
|
47
|
-
|
48
|
-
# An IO::WaitReadable means there may be more IO but this
|
49
|
-
# IO object is not ready to be read from yet. No problem,
|
50
|
-
# we read as much as we can, so we break.
|
51
|
-
breakable = true
|
52
|
-
elsif e.is_a?(Errno::EAGAIN)
|
53
|
-
# Otherwise, we just look for the EAGAIN error which should be
|
54
|
-
# all that IO::WaitReadable does in Ruby 1.9.
|
55
|
-
breakable = true
|
56
|
-
end
|
57
|
-
|
58
|
-
# Break out if we're supposed to. Otherwise re-raise the error
|
59
|
-
# because it is a real problem.
|
60
|
-
break if breakable
|
61
|
-
raise
|
41
|
+
rescue EOFError, Errno::EAGAIN, ::IO::WaitReadable
|
42
|
+
break
|
62
43
|
end
|
63
44
|
end
|
64
45
|
|
65
46
|
data
|
66
47
|
end
|
67
|
-
|
68
48
|
end
|
69
49
|
end
|
70
50
|
end
|
@@ -30,8 +30,7 @@ module Vagrant
|
|
30
30
|
return true
|
31
31
|
end
|
32
32
|
rescue Timeout::Error, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, \
|
33
|
-
Errno::ENETUNREACH, Errno::EACCES, Errno::ENOTCONN
|
34
|
-
Errno::EADDRNOTAVAIL
|
33
|
+
Errno::ENETUNREACH, Errno::EACCES, Errno::ENOTCONN
|
35
34
|
# Any of the above exceptions signal that the port is closed.
|
36
35
|
return false
|
37
36
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Util
|
3
|
+
class MapCommandOptions
|
4
|
+
# Given a hash map of user specified argments, will generate
|
5
|
+
# a list. Set the key to the command flag, and the value to
|
6
|
+
# it's value. If the value is boolean (true), only the flag is
|
7
|
+
# added. eg.
|
8
|
+
# {a: "opt-a", b: true} -> ["--a", "opt-a", "--b"]
|
9
|
+
#
|
10
|
+
# @param [Hash] map of commands
|
11
|
+
# @param [String] string prepended to cmd line flags (keys)
|
12
|
+
#
|
13
|
+
# @return[Array<String>] commands in list form
|
14
|
+
def self.map_to_command_options(map, cmd_flag="--")
|
15
|
+
opt_list = []
|
16
|
+
if map == nil
|
17
|
+
return opt_list
|
18
|
+
end
|
19
|
+
map.each do |k, v|
|
20
|
+
# If the value is true (bool) add the key as the cmd flag
|
21
|
+
if v.is_a?(TrueClass)
|
22
|
+
opt_list.push("#{cmd_flag}#{k}")
|
23
|
+
# If the value is a string, add the key as the flag, and value as the flags argument
|
24
|
+
elsif v.is_a?(String)
|
25
|
+
opt_list.push("#{cmd_flag}#{k}")
|
26
|
+
opt_list.push(v)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
return opt_list
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Util
|
5
|
+
class Numeric
|
6
|
+
|
7
|
+
# Authors Note: This conversion has been borrowed from the ActiveSupport Numeric class
|
8
|
+
# Conversion helper constants
|
9
|
+
KILOBYTE = 1024
|
10
|
+
MEGABYTE = KILOBYTE * 1024
|
11
|
+
GIGABYTE = MEGABYTE * 1024
|
12
|
+
TERABYTE = GIGABYTE * 1024
|
13
|
+
PETABYTE = TERABYTE * 1024
|
14
|
+
EXABYTE = PETABYTE * 1024
|
15
|
+
|
16
|
+
BYTES_CONVERSION_MAP = {KB: KILOBYTE, MB: MEGABYTE, GB: GIGABYTE, TB: TERABYTE,
|
17
|
+
PB: PETABYTE, EB: EXABYTE}
|
18
|
+
|
19
|
+
# Regex borrowed from the vagrant-disksize config class
|
20
|
+
SHORTHAND_MATCH_REGEX = /^(?<number>[0-9]+)\s?(?<unit>KB|MB|GB|TB)?$/
|
21
|
+
|
22
|
+
class << self
|
23
|
+
LOGGER = Log4r::Logger.new("vagrant::util::numeric")
|
24
|
+
|
25
|
+
# A helper that converts a shortcut string to its bytes representation.
|
26
|
+
# The expected format of `str` is essentially: "<Number>XX"
|
27
|
+
# Where `XX` is shorthand for KB, MB, GB, TB, PB, or EB. For example, 50 megabytes:
|
28
|
+
#
|
29
|
+
# str = "50MB"
|
30
|
+
#
|
31
|
+
# @param [String] - str
|
32
|
+
# @return [Integer,nil] - bytes - returns nil if method fails to convert to bytes
|
33
|
+
def string_to_bytes(str)
|
34
|
+
bytes = nil
|
35
|
+
|
36
|
+
str = str.to_s.strip
|
37
|
+
matches = SHORTHAND_MATCH_REGEX.match(str)
|
38
|
+
if matches
|
39
|
+
number = matches[:number].to_i
|
40
|
+
unit = matches[:unit].to_sym
|
41
|
+
|
42
|
+
if BYTES_CONVERSION_MAP.key?(unit)
|
43
|
+
bytes = number * BYTES_CONVERSION_MAP[unit]
|
44
|
+
else
|
45
|
+
LOGGER.error("An invalid unit or format was given, string_to_bytes cannot convert #{str}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
bytes
|
50
|
+
end
|
51
|
+
|
52
|
+
# Rounds actual value to two decimal places
|
53
|
+
#
|
54
|
+
# @param [Integer] bytes
|
55
|
+
# @return [Integer] megabytes - bytes representation in megabytes
|
56
|
+
def bytes_to_megabytes(bytes)
|
57
|
+
(bytes / MEGABYTE.to_f).round(2)
|
58
|
+
end
|
59
|
+
|
60
|
+
# @private
|
61
|
+
# Reset the cached values for platform. This is not considered a public
|
62
|
+
# API and should only be used for testing.
|
63
|
+
def reset!
|
64
|
+
instance_variables.each(&method(:remove_instance_variable))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -213,13 +213,20 @@ module Vagrant
|
|
213
213
|
return path if !cygwin?
|
214
214
|
|
215
215
|
# Replace all "\" with "/", otherwise cygpath doesn't work.
|
216
|
-
path = path
|
216
|
+
path = unix_windows_path(path)
|
217
217
|
|
218
218
|
# Call out to cygpath and gather the result
|
219
219
|
process = Subprocess.execute("cygpath", "-w", "-l", "-a", path.to_s)
|
220
220
|
return process.stdout.chomp
|
221
221
|
end
|
222
222
|
|
223
|
+
# This takes any path and converts Windows-style path separators
|
224
|
+
# to Unix-like path separators.
|
225
|
+
# @return [String]
|
226
|
+
def unix_windows_path(path)
|
227
|
+
path.gsub("\\", "/")
|
228
|
+
end
|
229
|
+
|
223
230
|
# This checks if the filesystem is case sensitive. This is not a
|
224
231
|
# 100% correct check, since it is possible that the temporary
|
225
232
|
# directory runs a different filesystem than the root directory.
|
@@ -26,6 +26,10 @@ module VagrantPlugins
|
|
26
26
|
options[:global] = g
|
27
27
|
end
|
28
28
|
|
29
|
+
o.on("-f", "--force", "Force checks for latest box updates") do |f|
|
30
|
+
options[:force] = f
|
31
|
+
end
|
32
|
+
|
29
33
|
build_download_options(o, download_options)
|
30
34
|
end
|
31
35
|
|
@@ -40,7 +44,7 @@ module VagrantPlugins
|
|
40
44
|
|
41
45
|
with_target_vms(argv) do |machine|
|
42
46
|
@env.action_runner.run(Vagrant::Action.action_box_outdated, {
|
43
|
-
box_outdated_force:
|
47
|
+
box_outdated_force: options[:force],
|
44
48
|
box_outdated_refresh: true,
|
45
49
|
box_outdated_success_ui: true,
|
46
50
|
machine: machine,
|
@@ -73,7 +77,15 @@ module VagrantPlugins
|
|
73
77
|
end
|
74
78
|
|
75
79
|
current = Gem::Version.new(box.version)
|
76
|
-
|
80
|
+
box_versions = md.versions(provider: box.provider)
|
81
|
+
|
82
|
+
if box_versions.empty?
|
83
|
+
latest_box_version = box_versions.last.to_i
|
84
|
+
else
|
85
|
+
latest_box_version = box_versions.last
|
86
|
+
end
|
87
|
+
|
88
|
+
latest = Gem::Version.new(latest_box_version)
|
77
89
|
if latest <= current
|
78
90
|
@env.ui.success(I18n.t(
|
79
91
|
"vagrant.box_up_to_date",
|
@@ -55,7 +55,7 @@ module VagrantPlugins
|
|
55
55
|
argv = parse_options(opts)
|
56
56
|
return if !argv
|
57
57
|
|
58
|
-
if argv.empty? || argv.length > 4 || argv.length < 3
|
58
|
+
if argv.empty? || argv.length > 4 || argv.length < 3 || (argv.length == 3 && !options[:url])
|
59
59
|
raise Vagrant::Errors::CLIInvalidUsage,
|
60
60
|
help: opts.help.chomp
|
61
61
|
end
|
@@ -15,6 +15,9 @@ module VagrantPlugins
|
|
15
15
|
o.separator "can be restored via `vagrant snapshot restore` at any point in the"
|
16
16
|
o.separator "future to get back to this exact machine state."
|
17
17
|
o.separator ""
|
18
|
+
o.separator "If no vm-name is given, Vagrant will take a snapshot of"
|
19
|
+
o.separator "the entire environment with the same snapshot name."
|
20
|
+
o.separator ""
|
18
21
|
o.separator "Snapshots are useful for experimenting in a machine and being able"
|
19
22
|
o.separator "to rollback quickly."
|
20
23
|
|
@@ -31,20 +34,22 @@ module VagrantPlugins
|
|
31
34
|
help: opts.help.chomp
|
32
35
|
end
|
33
36
|
|
34
|
-
|
35
|
-
# If there is a name given, we need to remove it and save it as `name`. Otherwise
|
36
|
-
# `with_target_vms` will treat the snapshot name as a guest name.
|
37
|
-
if argv.size < 2
|
38
|
-
name = argv.first
|
39
|
-
else
|
40
|
-
name = argv.pop
|
41
|
-
end
|
37
|
+
name = argv.pop
|
42
38
|
|
43
39
|
with_target_vms(argv) do |vm|
|
44
40
|
if !vm.provider.capability?(:snapshot_list)
|
45
41
|
raise Vagrant::Errors::SnapshotNotSupported
|
46
42
|
end
|
47
43
|
|
44
|
+
# In this case, no vm name was given, and we are iterating over the
|
45
|
+
# entire environment. If a vm hasn't been created yet, we can't list
|
46
|
+
# its snapshots
|
47
|
+
if vm.id.nil?
|
48
|
+
@env.ui.warn(I18n.t("vagrant.commands.snapshot.save.vm_not_created",
|
49
|
+
name: vm.name))
|
50
|
+
next
|
51
|
+
end
|
52
|
+
|
48
53
|
snapshot_list = vm.provider.capability(:snapshot_list)
|
49
54
|
|
50
55
|
if !snapshot_list.include? name
|
@@ -55,7 +55,7 @@ module VagrantPlugins
|
|
55
55
|
proxy_command: ssh_info[:proxy_command],
|
56
56
|
ssh_command: ssh_info[:ssh_command],
|
57
57
|
forward_env: ssh_info[:forward_env],
|
58
|
-
config: ssh_info[:config]
|
58
|
+
config: ssh_info[:config]
|
59
59
|
}
|
60
60
|
|
61
61
|
# Render the template and output directly to STDOUT
|
@@ -20,6 +20,7 @@ module VagrantPlugins
|
|
20
20
|
module CommunicatorSSH
|
21
21
|
# This class provides communication with the VM via SSH.
|
22
22
|
class Communicator < Vagrant.plugin("2", :communicator)
|
23
|
+
READY_COMMAND=""
|
23
24
|
# Marker for start of PTY enabled command output
|
24
25
|
PTY_DELIM_START = "bccbb768c119429488cfd109aacea6b5-pty"
|
25
26
|
# Marker for end of PTY enabled command output
|
@@ -65,7 +66,7 @@ module VagrantPlugins
|
|
65
66
|
while true
|
66
67
|
ssh_info = @machine.ssh_info
|
67
68
|
break if ssh_info
|
68
|
-
sleep
|
69
|
+
sleep(0.5)
|
69
70
|
end
|
70
71
|
|
71
72
|
# Got it! Let the user know what we're connecting to.
|
@@ -155,7 +156,7 @@ module VagrantPlugins
|
|
155
156
|
end
|
156
157
|
|
157
158
|
# Verify the shell is valid
|
158
|
-
if execute(
|
159
|
+
if execute(self.class.const_get(:READY_COMMAND), error_check: false) != 0
|
159
160
|
raise Vagrant::Errors::SSHInvalidShell
|
160
161
|
end
|
161
162
|
|
@@ -168,6 +169,7 @@ module VagrantPlugins
|
|
168
169
|
|
169
170
|
# If we used a password, then insert the insecure key
|
170
171
|
ssh_info = @machine.ssh_info
|
172
|
+
return if ssh_info.nil?
|
171
173
|
insert = ssh_info[:password] && ssh_info[:private_key_path].empty?
|
172
174
|
ssh_info[:private_key_path].each do |pk|
|
173
175
|
if insecure_key?(pk)
|
@@ -227,6 +229,7 @@ module VagrantPlugins
|
|
227
229
|
command: command,
|
228
230
|
shell: nil,
|
229
231
|
sudo: false,
|
232
|
+
force_raw: false
|
230
233
|
}.merge(opts || {})
|
231
234
|
|
232
235
|
opts[:good_exit] = Array(opts[:good_exit])
|
@@ -238,6 +241,7 @@ module VagrantPlugins
|
|
238
241
|
shell_opts = {
|
239
242
|
sudo: opts[:sudo],
|
240
243
|
shell: opts[:shell],
|
244
|
+
force_raw: opts[:force_raw]
|
241
245
|
}
|
242
246
|
|
243
247
|
shell_execute(connection, command, **shell_opts) do |type, data|
|
@@ -354,6 +358,11 @@ module VagrantPlugins
|
|
354
358
|
wait_for_ready(5)
|
355
359
|
end
|
356
360
|
|
361
|
+
def generate_environment_export(env_key, env_value)
|
362
|
+
template = machine_config_ssh.export_command_template
|
363
|
+
template.sub("%ENV_KEY%", env_key).sub("%ENV_VALUE%", env_value) + "\n"
|
364
|
+
end
|
365
|
+
|
357
366
|
protected
|
358
367
|
|
359
368
|
# Opens an SSH connection and yields it to a block.
|
@@ -398,14 +407,6 @@ module VagrantPlugins
|
|
398
407
|
auth_methods << "publickey" if ssh_info[:private_key_path]
|
399
408
|
auth_methods << "password" if ssh_info[:password]
|
400
409
|
|
401
|
-
# yanked directly from ruby's Net::SSH, but with `none` last
|
402
|
-
# TODO: Remove this once Vagrant has updated its dependency on Net:SSH
|
403
|
-
# to be > 4.1.0, which should include this fix.
|
404
|
-
cipher_array = Net::SSH::Transport::Algorithms::ALGORITHMS[:encryption].dup
|
405
|
-
if cipher_array.delete("none")
|
406
|
-
cipher_array.push("none")
|
407
|
-
end
|
408
|
-
|
409
410
|
# Build the options we'll use to initiate the connection via Net::SSH
|
410
411
|
common_connect_opts = {
|
411
412
|
auth_methods: auth_methods,
|
@@ -416,10 +417,9 @@ module VagrantPlugins
|
|
416
417
|
verify_host_key: ssh_info[:verify_host_key],
|
417
418
|
password: ssh_info[:password],
|
418
419
|
port: ssh_info[:port],
|
419
|
-
timeout:
|
420
|
+
timeout: ssh_info[:connect_timeout],
|
420
421
|
user_known_hosts_file: [],
|
421
|
-
verbose: :debug
|
422
|
-
encryption: cipher_array,
|
422
|
+
verbose: :debug
|
423
423
|
}
|
424
424
|
|
425
425
|
# Connect to SSH, giving it a few tries
|
@@ -628,7 +628,7 @@ module VagrantPlugins
|
|
628
628
|
end
|
629
629
|
|
630
630
|
# Set the terminal
|
631
|
-
ch2.send_data
|
631
|
+
ch2.send_data(generate_environment_export("TERM", "vt100"))
|
632
632
|
|
633
633
|
# Set SSH_AUTH_SOCK if we are in sudo and forwarding agent.
|
634
634
|
# This is to work around often misconfigured boxes where
|
@@ -651,7 +651,7 @@ module VagrantPlugins
|
|
651
651
|
@logger.warn("No SSH_AUTH_SOCK found despite forward_agent being set.")
|
652
652
|
else
|
653
653
|
@logger.info("Setting SSH_AUTH_SOCK remotely: #{auth_socket}")
|
654
|
-
ch2.send_data
|
654
|
+
ch2.send_data(generate_environment_export("SSH_AUTH_SOCK", auth_socket))
|
655
655
|
end
|
656
656
|
end
|
657
657
|
|
@@ -669,11 +669,11 @@ module VagrantPlugins
|
|
669
669
|
data += "printf #{PTY_DELIM_END}\n"
|
670
670
|
data += "exit $exitcode\n"
|
671
671
|
data = data.force_encoding('ASCII-8BIT')
|
672
|
-
ch2.send_data
|
672
|
+
ch2.send_data(data)
|
673
673
|
else
|
674
|
-
ch2.send_data
|
674
|
+
ch2.send_data("printf '#{CMD_GARBAGE_MARKER}'\n(>&2 printf '#{CMD_GARBAGE_MARKER}')\n#{command}\n".force_encoding('ASCII-8BIT'))
|
675
675
|
# Remember to exit or this channel will hang open
|
676
|
-
ch2.send_data
|
676
|
+
ch2.send_data("exit\n")
|
677
677
|
end
|
678
678
|
|
679
679
|
# Send eof to let server know we're done
|
@@ -759,11 +759,6 @@ module VagrantPlugins
|
|
759
759
|
return File.read(path).chomp == source_path.read.chomp
|
760
760
|
end
|
761
761
|
|
762
|
-
def generate_environment_export(env_key, env_value)
|
763
|
-
template = machine_config_ssh.export_command_template
|
764
|
-
template.sub("%ENV_KEY%", env_key).sub("%ENV_VALUE%", env_value) + "\n"
|
765
|
-
end
|
766
|
-
|
767
762
|
def create_remote_directory(dir)
|
768
763
|
execute("mkdir -p \"#{dir}\"")
|
769
764
|
end
|