vagrant-unbundled 2.2.7.0 → 2.2.16.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 +2 -0
- data/CHANGELOG.md +228 -0
- data/Gemfile +1 -1
- data/README.md +9 -51
- data/RELEASE.md +1 -1
- data/bin/vagrant +50 -1
- data/contrib/README.md +1 -0
- data/contrib/sudoers/linux-suse +2 -2
- data/contrib/zsh/_vagrant +738 -0
- data/contrib/zsh/generate_zsh_completion.rb +165 -0
- data/lib/vagrant.rb +28 -5
- data/lib/vagrant/action.rb +7 -0
- data/lib/vagrant/action/builder.rb +184 -38
- data/lib/vagrant/action/builtin/box_add.rb +24 -8
- data/lib/vagrant/action/builtin/box_check_outdated.rb +2 -1
- data/lib/vagrant/action/builtin/cleanup_disks.rb +56 -0
- data/lib/vagrant/action/builtin/cloud_init_setup.rb +122 -0
- data/lib/vagrant/action/builtin/cloud_init_wait.rb +30 -0
- data/lib/vagrant/action/builtin/delayed.rb +26 -0
- data/lib/vagrant/action/builtin/disk.rb +14 -1
- data/lib/vagrant/action/builtin/handle_box.rb +3 -1
- data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +28 -9
- data/lib/vagrant/action/builtin/has_provisioner.rb +36 -0
- data/lib/vagrant/action/builtin/mixin_provisioners.rb +1 -0
- data/lib/vagrant/action/builtin/mixin_synced_folders.rb +20 -21
- data/lib/vagrant/action/builtin/set_hostname.rb +5 -1
- data/lib/vagrant/action/builtin/synced_folders.rb +16 -0
- data/lib/vagrant/action/builtin/trigger.rb +37 -0
- data/lib/vagrant/action/hook.rb +76 -23
- data/lib/vagrant/action/runner.rb +12 -27
- data/lib/vagrant/action/warden.rb +28 -31
- data/lib/vagrant/box.rb +11 -4
- data/lib/vagrant/box_collection.rb +1 -1
- data/lib/vagrant/bundler.rb +310 -61
- data/lib/vagrant/cli.rb +4 -2
- data/lib/vagrant/environment.rb +1 -0
- data/lib/vagrant/errors.rb +69 -1
- data/lib/vagrant/machine.rb +64 -11
- data/lib/vagrant/machine_index.rb +28 -1
- data/lib/vagrant/patches/net-ssh.rb +186 -0
- data/lib/vagrant/plugin/manager.rb +45 -16
- data/lib/vagrant/plugin/v2/command.rb +7 -2
- data/lib/vagrant/plugin/v2/components.rb +6 -0
- data/lib/vagrant/plugin/v2/manager.rb +67 -0
- data/lib/vagrant/plugin/v2/plugin.rb +13 -0
- data/lib/vagrant/plugin/v2/synced_folder.rb +50 -0
- data/lib/vagrant/plugin/v2/trigger.rb +64 -25
- data/lib/vagrant/shared_helpers.rb +36 -0
- data/lib/vagrant/ui.rb +43 -2
- data/lib/vagrant/util.rb +2 -0
- data/lib/vagrant/util/ansi_escape_code_remover.rb +1 -1
- data/lib/vagrant/util/caps.rb +48 -0
- data/lib/vagrant/util/credential_scrubber.rb +1 -1
- data/lib/vagrant/util/curl_helper.rb +12 -8
- data/lib/vagrant/util/directory.rb +19 -0
- data/lib/vagrant/util/downloader.rb +10 -5
- data/lib/vagrant/util/guest_hosts.rb +68 -0
- data/lib/vagrant/util/guest_inspection.rb +9 -1
- data/lib/vagrant/util/install_cli_autocomplete.rb +118 -0
- data/lib/vagrant/util/io.rb +7 -27
- data/lib/vagrant/util/ipv4_interfaces.rb +15 -0
- data/lib/vagrant/util/is_port_open.rb +8 -19
- data/lib/vagrant/util/map_command_options.rb +33 -0
- data/lib/vagrant/util/mime.rb +92 -0
- data/lib/vagrant/util/network_ip.rb +11 -1
- data/lib/vagrant/util/numeric.rb +28 -0
- data/lib/vagrant/util/platform.rb +10 -2
- data/lib/vagrant/util/powershell.rb +31 -15
- data/lib/vagrant/util/subprocess.rb +9 -1
- data/lib/vagrant/util/template_renderer.rb +2 -2
- data/lib/vagrant/util/uploader.rb +7 -4
- data/lib/vagrant/vagrantfile.rb +2 -2
- data/plugins/commands/autocomplete/command/install.rb +49 -0
- data/plugins/commands/autocomplete/command/root.rb +64 -0
- data/plugins/commands/autocomplete/plugin.rb +18 -0
- data/plugins/commands/cap/command.rb +5 -1
- data/plugins/commands/cloud/auth/login.rb +20 -23
- data/plugins/commands/cloud/auth/logout.rb +2 -10
- data/plugins/commands/cloud/auth/middleware/add_authentication.rb +60 -31
- data/plugins/commands/cloud/auth/middleware/add_downloader_authentication.rb +64 -0
- data/plugins/commands/cloud/auth/whoami.rb +18 -20
- data/plugins/commands/cloud/box/create.rb +33 -29
- data/plugins/commands/cloud/box/delete.rb +30 -24
- data/plugins/commands/cloud/box/show.rb +41 -31
- data/plugins/commands/cloud/box/update.rb +34 -26
- data/plugins/commands/cloud/client/client.rb +55 -79
- data/plugins/commands/cloud/list.rb +3 -4
- data/plugins/commands/cloud/locales/en.yml +15 -11
- data/plugins/commands/cloud/plugin.rb +10 -0
- data/plugins/commands/cloud/provider/create.rb +38 -28
- data/plugins/commands/cloud/provider/delete.rb +39 -29
- data/plugins/commands/cloud/provider/update.rb +37 -28
- data/plugins/commands/cloud/provider/upload.rb +53 -33
- data/plugins/commands/cloud/publish.rb +193 -106
- data/plugins/commands/cloud/search.rb +34 -21
- data/plugins/commands/cloud/util.rb +273 -161
- data/plugins/commands/cloud/version/create.rb +33 -28
- data/plugins/commands/cloud/version/delete.rb +35 -28
- data/plugins/commands/cloud/version/release.rb +35 -29
- data/plugins/commands/cloud/version/revoke.rb +36 -29
- data/plugins/commands/cloud/version/update.rb +29 -25
- data/plugins/commands/destroy/command.rb +7 -7
- data/plugins/commands/login/plugin.rb +0 -13
- data/plugins/commands/ssh_config/command.rb +1 -1
- data/plugins/communicators/ssh/communicator.rb +25 -24
- data/plugins/communicators/winrm/config.rb +1 -1
- data/plugins/communicators/winrm/helper.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/change_host_name.rb +10 -11
- data/plugins/guests/alpine/cap/configure_networks.rb +1 -1
- data/plugins/guests/alt/cap/change_host_name.rb +40 -53
- data/plugins/guests/arch/cap/change_host_name.rb +5 -14
- data/plugins/guests/arch/cap/configure_networks.rb +27 -10
- data/plugins/guests/arch/cap/smb.rb +1 -1
- data/plugins/guests/atomic/cap/change_host_name.rb +5 -14
- 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/change_host_name.rb +10 -6
- data/plugins/guests/darwin/cap/darwin_version.rb +40 -0
- data/plugins/guests/darwin/cap/mount_smb_shared_folder.rb +1 -1
- data/plugins/guests/darwin/cap/mount_vmware_shared_folder.rb +33 -10
- data/plugins/guests/darwin/plugin.rb +15 -0
- data/plugins/guests/debian/cap/change_host_name.rb +12 -11
- data/plugins/guests/debian/cap/configure_networks.rb +14 -6
- data/plugins/guests/esxi/cap/public_key.rb +3 -1
- data/plugins/guests/fedora/guest.rb +4 -4
- data/plugins/guests/freebsd/cap/change_host_name.rb +10 -6
- data/plugins/guests/gentoo/cap/change_host_name.rb +14 -22
- data/plugins/guests/haiku/cap/rsync.rb +19 -0
- data/plugins/guests/haiku/plugin.rb +15 -0
- data/plugins/guests/linux/cap/change_host_name.rb +46 -0
- data/plugins/guests/linux/cap/halt.rb +9 -1
- data/plugins/guests/linux/cap/mount_smb_shared_folder.rb +25 -34
- data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +10 -11
- data/plugins/guests/linux/cap/persist_mount_shared_folder.rb +74 -0
- data/plugins/guests/linux/cap/reboot.rb +36 -7
- data/plugins/guests/linux/plugin.rb +10 -0
- data/plugins/guests/omnios/cap/change_host_name.rb +10 -16
- data/plugins/guests/openbsd/cap/change_host_name.rb +10 -6
- data/plugins/guests/openwrt/cap/change_host_name.rb +19 -0
- data/plugins/guests/openwrt/cap/halt.rb +16 -0
- data/plugins/guests/openwrt/cap/insert_public_key.rb +20 -0
- data/plugins/guests/openwrt/cap/remove_public_key.rb +22 -0
- data/plugins/guests/openwrt/cap/rsync.rb +35 -0
- data/plugins/guests/openwrt/guest.rb +23 -0
- data/plugins/guests/openwrt/plugin.rb +61 -0
- data/plugins/guests/photon/cap/change_host_name.rb +9 -15
- data/plugins/guests/pld/cap/change_host_name.rb +11 -17
- data/plugins/guests/redhat/cap/change_host_name.rb +14 -5
- data/plugins/guests/redhat/cap/flavor.rb +3 -1
- data/plugins/guests/redhat/cap/smb.rb +20 -0
- data/plugins/guests/redhat/plugin.rb +5 -0
- data/plugins/guests/slackware/cap/change_host_name.rb +11 -17
- data/plugins/guests/solaris11/plugin.rb +5 -0
- data/plugins/guests/suse/cap/change_host_name.rb +31 -9
- data/plugins/guests/windows/cap/public_key.rb +3 -3
- data/plugins/guests/windows/cap/reboot.rb +10 -5
- data/plugins/hosts/darwin/cap/fs_iso.rb +49 -0
- data/plugins/hosts/darwin/plugin.rb +10 -0
- data/plugins/hosts/linux/cap/fs_iso.rb +49 -0
- data/plugins/hosts/linux/cap/nfs.rb +1 -0
- data/plugins/hosts/linux/cap/rdp.rb +1 -1
- data/plugins/hosts/linux/plugin.rb +10 -0
- data/plugins/hosts/windows/cap/fs_iso.rb +48 -0
- data/plugins/hosts/windows/cap/rdp.rb +1 -1
- data/plugins/hosts/windows/plugin.rb +15 -0
- data/plugins/kernel_v2/config/cloud_init.rb +133 -0
- data/plugins/kernel_v2/config/disk.rb +67 -14
- data/plugins/kernel_v2/config/ssh_connect.rb +24 -0
- data/plugins/kernel_v2/config/vm.rb +155 -21
- data/plugins/kernel_v2/config/vm_provisioner.rb +13 -2
- data/plugins/kernel_v2/config/vm_trigger.rb +6 -5
- data/plugins/providers/docker/action.rb +8 -17
- data/plugins/providers/docker/action/forwarded_ports.rb +2 -0
- data/plugins/providers/docker/action/prepare_forwarded_port_collision_params.rb +61 -0
- data/plugins/providers/docker/cap/has_communicator.rb +11 -0
- data/plugins/providers/docker/communicator.rb +1 -1
- data/plugins/providers/docker/driver.rb +58 -7
- data/plugins/providers/docker/plugin.rb +5 -0
- data/plugins/providers/hyperv/action.rb +3 -1
- data/plugins/providers/hyperv/action/configure.rb +8 -0
- data/plugins/providers/hyperv/action/export.rb +4 -2
- data/plugins/providers/hyperv/cap/cleanup_disks.rb +54 -0
- data/plugins/providers/hyperv/cap/configure_disks.rb +200 -0
- data/plugins/providers/hyperv/cap/validate_disk_ext.rb +34 -0
- data/plugins/providers/hyperv/config.rb +5 -0
- data/plugins/providers/hyperv/driver.rb +90 -9
- data/plugins/providers/hyperv/plugin.rb +25 -0
- data/plugins/providers/hyperv/scripts/attach_disk_drive.ps1 +28 -0
- data/plugins/providers/hyperv/scripts/dismount_vhd.ps1 +13 -0
- data/plugins/providers/hyperv/scripts/get_vhd.ps1 +16 -0
- data/plugins/providers/hyperv/scripts/get_vm_status.ps1 +1 -1
- data/plugins/providers/hyperv/scripts/list_hdds.ps1 +17 -0
- data/plugins/providers/hyperv/scripts/new_vhd.ps1 +31 -0
- data/plugins/providers/hyperv/scripts/remove_disk_drive.ps1 +25 -0
- data/plugins/providers/hyperv/scripts/resize_disk_drive.ps1 +18 -0
- data/plugins/providers/hyperv/scripts/set_enhanced_session_transport_type.ps1 +24 -0
- data/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 +3 -3
- data/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 +14 -6
- data/plugins/providers/virtualbox/action.rb +13 -1
- data/plugins/providers/virtualbox/action/export.rb +4 -2
- data/plugins/providers/virtualbox/action/forward_ports.rb +2 -2
- data/plugins/providers/virtualbox/action/import.rb +8 -4
- data/plugins/providers/virtualbox/action/network.rb +12 -5
- 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 +85 -0
- data/plugins/providers/virtualbox/cap/configure_disks.rb +440 -0
- data/plugins/providers/virtualbox/cap/mount_options.rb +40 -0
- data/plugins/providers/virtualbox/cap/validate_disk_ext.rb +34 -0
- data/plugins/providers/virtualbox/driver/base.rb +15 -0
- data/plugins/providers/virtualbox/driver/meta.rb +16 -2
- data/plugins/providers/virtualbox/driver/version_5_0.rb +217 -2
- data/plugins/providers/virtualbox/driver/version_6_1.rb +23 -0
- data/plugins/providers/virtualbox/model/storage_controller.rb +135 -0
- data/plugins/providers/virtualbox/model/storage_controller_array.rb +98 -0
- data/plugins/providers/virtualbox/plugin.rb +42 -0
- data/plugins/providers/virtualbox/provider.rb +2 -1
- data/plugins/providers/virtualbox/synced_folder.rb +1 -0
- data/plugins/provisioners/ansible/cap/guest/alpine/ansible_install.rb +44 -0
- data/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb +1 -1
- 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/bootstrap-salt.sh +7 -4
- data/plugins/provisioners/salt/provisioner.rb +4 -0
- data/plugins/provisioners/shell/config.rb +1 -6
- data/plugins/provisioners/shell/provisioner.rb +61 -26
- data/plugins/synced_folders/nfs/synced_folder.rb +3 -1
- data/plugins/synced_folders/smb/cap/default_fstab_modification.rb +11 -0
- data/plugins/synced_folders/smb/cap/mount_options.rb +56 -0
- data/plugins/synced_folders/smb/plugin.rb +20 -0
- data/plugins/synced_folders/smb/synced_folder.rb +2 -2
- data/plugins/synced_folders/unix_mount_helpers.rb +14 -0
- data/scripts/website_push_www.sh +1 -1
- data/templates/commands/init/Vagrantfile.min.erb +3 -0
- data/templates/guests/arch/{network_dhcp.erb → default_network/network_dhcp.erb} +0 -0
- data/templates/guests/arch/{network_static.erb → default_network/network_static.erb} +0 -0
- data/templates/guests/arch/{network_static6.erb → default_network/network_static6.erb} +0 -0
- data/templates/guests/arch/systemd_networkd/network_dhcp.erb +6 -0
- data/templates/guests/arch/systemd_networkd/network_static.erb +9 -0
- data/templates/guests/arch/systemd_networkd/network_static6.erb +9 -0
- data/templates/guests/linux/etc_fstab.erb +6 -0
- data/templates/guests/nixos/network.erb +5 -6
- data/templates/locales/en.yml +221 -5
- data/templates/locales/providers_docker.yml +4 -0
- data/templates/nfs/exports_darwin.erb +1 -1
- data/vagrant.gemspec +14 -20
- data/version.txt +1 -1
- metadata +5092 -8978
- data/lib/vagrant/action/builtin/after_trigger.rb +0 -31
- data/lib/vagrant/action/builtin/before_trigger.rb +0 -28
- data/plugins/commands/login/client.rb +0 -253
- data/plugins/commands/login/command.rb +0 -137
- data/plugins/commands/login/errors.rb +0 -24
- data/plugins/commands/login/locales/en.yml +0 -49
- data/plugins/provisioners/docker/cap/redhat/docker_start_service.rb +0 -16
- data/scripts/website_push_docs.sh +0 -40
@@ -125,6 +125,14 @@ module Vagrant
|
|
125
125
|
Gem::Version.new(Vagrant::VERSION).prerelease?
|
126
126
|
end
|
127
127
|
|
128
|
+
# This returns true/false if the Vagrant should allow prerelease
|
129
|
+
# versions when resolving plugin dependency constraints
|
130
|
+
#
|
131
|
+
# @return [Boolean]
|
132
|
+
def self.allow_prerelease_dependencies?
|
133
|
+
!!ENV["VAGRANT_ALLOW_PRERELEASE"]
|
134
|
+
end
|
135
|
+
|
128
136
|
# This allows control over dependency resolution when installing
|
129
137
|
# plugins into vagrant. When true, dependency libraries that Vagrant
|
130
138
|
# core relies upon will be hard constraints.
|
@@ -186,4 +194,32 @@ module Vagrant
|
|
186
194
|
end
|
187
195
|
@_global_logger
|
188
196
|
end
|
197
|
+
|
198
|
+
# Add a new block of default CLI options which
|
199
|
+
# should be automatically added to all commands
|
200
|
+
#
|
201
|
+
# @param [Proc] block Proc instance containing OptParser configuration
|
202
|
+
# @return [nil]
|
203
|
+
def self.add_default_cli_options(block)
|
204
|
+
if !block.is_a?(Proc)
|
205
|
+
raise TypeError,
|
206
|
+
"Expecting type `Proc` but received `#{block.class}`"
|
207
|
+
end
|
208
|
+
if block.arity != 1 && block.arity != -1
|
209
|
+
raise ArgumentError,
|
210
|
+
"Proc must accept OptionParser argument"
|
211
|
+
end
|
212
|
+
@_default_cli_options = [] if !@_default_cli_options
|
213
|
+
@_default_cli_options << block
|
214
|
+
nil
|
215
|
+
end
|
216
|
+
|
217
|
+
# Array of default CLI options to automatically
|
218
|
+
# add to commands.
|
219
|
+
#
|
220
|
+
# @return [Array<Proc>] Default optparse options
|
221
|
+
def self.default_cli_options
|
222
|
+
@_default_cli_options = [] if !@_default_cli_options
|
223
|
+
@_default_cli_options.dup
|
224
|
+
end
|
189
225
|
end
|
data/lib/vagrant/ui.rb
CHANGED
@@ -75,6 +75,13 @@ module Vagrant
|
|
75
75
|
def machine(type, *data)
|
76
76
|
@logger.info("Machine: #{type} #{data.inspect}")
|
77
77
|
end
|
78
|
+
|
79
|
+
# Yields self (UI)
|
80
|
+
# Provides a way for selectively displaying or not displaying
|
81
|
+
# updating content like download progress.
|
82
|
+
def rewriting
|
83
|
+
yield self
|
84
|
+
end
|
78
85
|
end
|
79
86
|
|
80
87
|
# This is a UI implementation that does nothing.
|
@@ -220,7 +227,7 @@ module Vagrant
|
|
220
227
|
|
221
228
|
# This method handles actually outputting a message of a given type
|
222
229
|
# to the console.
|
223
|
-
def say(type, message,
|
230
|
+
def say(type, message, opts={})
|
224
231
|
defaults = { new_line: true, prefix: true }
|
225
232
|
opts = defaults.merge(@opts).merge(opts)
|
226
233
|
|
@@ -252,6 +259,31 @@ module Vagrant
|
|
252
259
|
end
|
253
260
|
end
|
254
261
|
|
262
|
+
|
263
|
+
class NonInteractive < Basic
|
264
|
+
def initialize
|
265
|
+
super
|
266
|
+
end
|
267
|
+
|
268
|
+
def rewriting
|
269
|
+
# no-op
|
270
|
+
end
|
271
|
+
|
272
|
+
def report_progress(progress, total, show_parts=true)
|
273
|
+
# no-op
|
274
|
+
end
|
275
|
+
|
276
|
+
def clear_line
|
277
|
+
@logger.warn("Using `clear line` in a non interactive ui")
|
278
|
+
say(:info, "\n", opts)
|
279
|
+
end
|
280
|
+
|
281
|
+
def ask(*args)
|
282
|
+
# Non interactive can't ask for input
|
283
|
+
raise Errors::UIExpectsTTY
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
255
287
|
# Prefixed wraps an existing UI and adds a prefix to it.
|
256
288
|
class Prefixed < Interface
|
257
289
|
# The prefix for `output` messages.
|
@@ -290,7 +322,9 @@ module Vagrant
|
|
290
322
|
|
291
323
|
[:clear_line, :report_progress].each do |method|
|
292
324
|
# By default do nothing, these aren't formatted
|
293
|
-
define_method(method)
|
325
|
+
define_method(method) do |*args|
|
326
|
+
@ui.send(method, *args)
|
327
|
+
end
|
294
328
|
end
|
295
329
|
|
296
330
|
# For machine-readable output, set the prefix in the
|
@@ -344,6 +378,13 @@ module Vagrant
|
|
344
378
|
"#{prefix}#{target} #{line}"
|
345
379
|
end.join("\n")
|
346
380
|
end
|
381
|
+
|
382
|
+
def rewriting
|
383
|
+
@ui.rewriting do |ui|
|
384
|
+
yield ui
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
347
388
|
end
|
348
389
|
|
349
390
|
# This is a UI implementation that outputs color for various types
|
data/lib/vagrant/util.rb
CHANGED
@@ -7,9 +7,11 @@ 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'
|
14
|
+
autoload :Numeric, 'vagrant/util/numeric'
|
13
15
|
autoload :Platform, 'vagrant/util/platform'
|
14
16
|
autoload :Retryable, 'vagrant/util/retryable'
|
15
17
|
autoload :SafeExec, 'vagrant/util/safe_exec'
|
@@ -19,7 +19,7 @@ module Vagrant
|
|
19
19
|
/\e\[\?[1-9][hl]/, # Matches \e[?2h
|
20
20
|
/\e\[20[hl]/, # Matches \e[20l]
|
21
21
|
/\e[DME78H]/, # Matches \eD, \eH, etc.
|
22
|
-
/\e\[[0-
|
22
|
+
/\e\[[0-3]?[JK]/, # Matches \e[0J, \e[K, etc.
|
23
23
|
]
|
24
24
|
|
25
25
|
# Take each matcher and replace it with emptiness.
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "tempfile"
|
2
|
+
require "fileutils"
|
3
|
+
require "pathname"
|
4
|
+
require "vagrant/util/directory"
|
5
|
+
require "vagrant/util/subprocess"
|
6
|
+
|
7
|
+
module Vagrant
|
8
|
+
module Util
|
9
|
+
module Caps
|
10
|
+
module BuildISO
|
11
|
+
|
12
|
+
# Builds an iso given a compatible iso_command
|
13
|
+
#
|
14
|
+
# @param [List<String>] command to build iso
|
15
|
+
# @param [Pathname] input directory for iso build
|
16
|
+
# @param [Pathname] output file for iso build
|
17
|
+
def build_iso(iso_command, source_directory, file_destination)
|
18
|
+
FileUtils.mkdir_p(file_destination.dirname)
|
19
|
+
if !file_destination.exist? || Vagrant::Util::Directory.directory_changed?(source_directory, file_destination.mtime)
|
20
|
+
result = Vagrant::Util::Subprocess.execute(*iso_command)
|
21
|
+
if result.exit_code != 0
|
22
|
+
raise Vagrant::Errors::ISOBuildFailed, cmd: iso_command.join(" "), stdout: result.stdout, stderr: result.stderr
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def ensure_output_iso(file_destination)
|
30
|
+
if file_destination.nil?
|
31
|
+
tmpfile = Tempfile.new(["vagrant", ".iso"])
|
32
|
+
file_destination = Pathname.new(tmpfile.path)
|
33
|
+
tmpfile.close
|
34
|
+
tmpfile.unlink
|
35
|
+
else
|
36
|
+
file_destination = Pathname.new(file_destination.to_s)
|
37
|
+
# If the file destination path is a folder, target the output to a randomly named
|
38
|
+
# file in that dir
|
39
|
+
if file_destination.extname != ".iso"
|
40
|
+
file_destination = file_destination.join("#{SecureRandom.hex(3)}_vagrant.iso")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
file_destination
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -32,7 +32,7 @@ module Vagrant
|
|
32
32
|
def self.desensitize(string)
|
33
33
|
string = string.to_s.dup
|
34
34
|
sensitive_strings.each do |remove|
|
35
|
-
string.gsub!(remove
|
35
|
+
string.gsub!(/(\W|^)#{Regexp.escape(remove)}(\W|$)/, "\\1#{REPLACEMENT_TEXT}\\2")
|
36
36
|
end
|
37
37
|
string
|
38
38
|
end
|
@@ -4,6 +4,7 @@ module Vagrant
|
|
4
4
|
|
5
5
|
# Hosts that do not require notification on redirect
|
6
6
|
SILENCED_HOSTS = [
|
7
|
+
"vagrantcloud-files-production.s3-accelerate.amazonaws.com".freeze,
|
7
8
|
"vagrantcloud.com".freeze,
|
8
9
|
"vagrantup.com".freeze
|
9
10
|
].freeze
|
@@ -21,6 +22,7 @@ module Vagrant
|
|
21
22
|
# Accumulate progress_data
|
22
23
|
progress_data << data
|
23
24
|
|
25
|
+
redirect_notify = false
|
24
26
|
while true
|
25
27
|
# If the download has been redirected and we are no longer downloading
|
26
28
|
# from the original host, notify the user that the target host has
|
@@ -30,15 +32,16 @@ module Vagrant
|
|
30
32
|
if !location.empty?
|
31
33
|
location_uri = URI.parse(location)
|
32
34
|
|
33
|
-
|
34
|
-
redirect_notify = false
|
35
|
+
if !location_uri.host.nil? && !redirect_notify
|
35
36
|
logger.info("download redirected to #{location}")
|
36
37
|
source_uri = URI.parse(source)
|
37
38
|
source_host = source_uri.host.to_s.split(".", 2).last
|
38
39
|
location_host = location_uri.host.to_s.split(".", 2).last
|
39
|
-
if
|
40
|
-
ui.
|
41
|
-
|
40
|
+
if location_host != source_host && !SILENCED_HOSTS.include?(location_host) && !SILENCED_HOSTS.include?(location_uri.host.to_s)
|
41
|
+
ui.rewriting do |_ui|
|
42
|
+
_ui.clear_line
|
43
|
+
_ui.detail "Download redirected to host: #{location_uri.host}"
|
44
|
+
end
|
42
45
|
end
|
43
46
|
redirect_notify = true
|
44
47
|
end
|
@@ -82,10 +85,11 @@ module Vagrant
|
|
82
85
|
# 9 - Time spent
|
83
86
|
# 10 - Time left
|
84
87
|
# 11 - Current speed
|
85
|
-
|
86
88
|
output = "Progress: #{columns[0]}% (Rate: #{columns[11]}/s, Estimated time remaining: #{columns[10]})"
|
87
|
-
ui.
|
88
|
-
|
89
|
+
ui.rewriting do |ui|
|
90
|
+
ui.clear_line
|
91
|
+
ui.detail(output, new_line: false)
|
92
|
+
end
|
89
93
|
end
|
90
94
|
end
|
91
95
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Util
|
5
|
+
class Directory
|
6
|
+
# Check if directory has any new updates
|
7
|
+
#
|
8
|
+
# @param [Pathname, String] Path to directory
|
9
|
+
# @param [Time] time to compare to eg. has any file in dir_path
|
10
|
+
# changed since this time
|
11
|
+
# @return [Boolean]
|
12
|
+
def self.directory_changed?(dir_path, threshold_time)
|
13
|
+
Dir.glob(Pathname.new(dir_path).join("**", "*")).any? do |path|
|
14
|
+
Pathname.new(path).mtime > threshold_time
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "cgi"
|
1
2
|
require "uri"
|
2
3
|
|
3
4
|
require "log4r"
|
@@ -28,8 +29,9 @@ module Vagrant
|
|
28
29
|
"vagrantup.com".freeze
|
29
30
|
].freeze
|
30
31
|
|
31
|
-
|
32
|
+
attr_accessor :source
|
32
33
|
attr_reader :destination
|
34
|
+
attr_accessor :headers
|
33
35
|
|
34
36
|
def initialize(source, destination, options=nil)
|
35
37
|
options ||= {}
|
@@ -41,8 +43,8 @@ module Vagrant
|
|
41
43
|
begin
|
42
44
|
url = URI.parse(@source)
|
43
45
|
if url.scheme && url.scheme.start_with?("http") && url.user
|
44
|
-
auth = "#{
|
45
|
-
auth += ":#{
|
46
|
+
auth = "#{CGI.unescape(url.user)}"
|
47
|
+
auth += ":#{CGI.unescape(url.password)}" if url.password
|
46
48
|
url.user = nil
|
47
49
|
url.password = nil
|
48
50
|
options[:auth] ||= auth
|
@@ -57,7 +59,7 @@ module Vagrant
|
|
57
59
|
@ca_cert = options[:ca_cert]
|
58
60
|
@ca_path = options[:ca_path]
|
59
61
|
@continue = options[:continue]
|
60
|
-
@headers = options[:headers]
|
62
|
+
@headers = Array(options[:headers])
|
61
63
|
@insecure = options[:insecure]
|
62
64
|
@ui = options[:ui]
|
63
65
|
@client_cert = options[:client_cert]
|
@@ -69,6 +71,7 @@ module Vagrant
|
|
69
71
|
:sha384 => options[:sha384],
|
70
72
|
:sha512 => options[:sha512]
|
71
73
|
}.compact
|
74
|
+
@extra_download_options = options[:box_extra_download_options] || []
|
72
75
|
end
|
73
76
|
|
74
77
|
# This executes the actual download, downloading the source file
|
@@ -183,6 +186,7 @@ module Vagrant
|
|
183
186
|
|
184
187
|
def execute_curl(options, subprocess_options, &data_proc)
|
185
188
|
options = options.dup
|
189
|
+
options.unshift("-q")
|
186
190
|
options << subprocess_options
|
187
191
|
|
188
192
|
# Create the callback that is called if we are interrupted
|
@@ -230,7 +234,6 @@ module Vagrant
|
|
230
234
|
def options
|
231
235
|
# Build the list of parameters to execute with cURL
|
232
236
|
options = [
|
233
|
-
"-q",
|
234
237
|
"--fail",
|
235
238
|
"--location",
|
236
239
|
"--max-redirs", "10", "--verbose",
|
@@ -245,6 +248,8 @@ module Vagrant
|
|
245
248
|
options << "-u" << @auth if @auth
|
246
249
|
options << "--location-trusted" if @location_trusted
|
247
250
|
|
251
|
+
options.concat(@extra_download_options)
|
252
|
+
|
248
253
|
if @headers
|
249
254
|
Array(@headers).each do |header|
|
250
255
|
options << "-H" << header
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Util
|
3
|
+
# Helper methods for modfiying guests /etc/hosts file
|
4
|
+
module GuestHosts
|
5
|
+
|
6
|
+
module Unix
|
7
|
+
DEAFAULT_LOOPBACK_CHECK_LIMIT = 5.freeze
|
8
|
+
|
9
|
+
# Add hostname to a loopback address on /etc/hosts if not already there
|
10
|
+
# Will insert name at the first free address of the form 127.0.X.1, up to
|
11
|
+
# the loop_bound
|
12
|
+
#
|
13
|
+
# @param [Communicator]
|
14
|
+
# @param [String] full hostanme
|
15
|
+
# @param [int] (option) defines the upper bound for searching for an available loopback address
|
16
|
+
def add_hostname_to_loopback_interface(comm, name, loop_bound=DEAFAULT_LOOPBACK_CHECK_LIMIT)
|
17
|
+
basename = name.split(".", 2)[0]
|
18
|
+
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
19
|
+
grep -w '#{name}' /etc/hosts || {
|
20
|
+
for i in #{[*1..loop_bound].join(' ')}; do
|
21
|
+
grep -w "127.0.${i}.1" /etc/hosts || {
|
22
|
+
echo "127.0.${i}.1 #{name} #{basename}" >> /etc/hosts
|
23
|
+
break
|
24
|
+
}
|
25
|
+
done
|
26
|
+
}
|
27
|
+
EOH
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Linux specific inspection helpers
|
32
|
+
module Linux
|
33
|
+
include Unix
|
34
|
+
# Remove any line in /etc/hosts that contains hostname,
|
35
|
+
# then add hostname with associated ip
|
36
|
+
#
|
37
|
+
# @param [Communicator]
|
38
|
+
# @param [String] full hostanme
|
39
|
+
# @param [String] target ip
|
40
|
+
def replace_host(comm, name, ip)
|
41
|
+
basename = name.split(".", 2)[0]
|
42
|
+
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
43
|
+
sed -i '/#{name}/d' /etc/hosts
|
44
|
+
sed -i'' '1i '#{ip}'\\t#{name}\\t#{basename}' /etc/hosts
|
45
|
+
EOH
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# BSD specific inspection helpers
|
50
|
+
module BSD
|
51
|
+
include Unix
|
52
|
+
# Remove any line in /etc/hosts that contains hostname,
|
53
|
+
# then add hostname with associated ip
|
54
|
+
#
|
55
|
+
# @param [Communicator]
|
56
|
+
# @param [String] full hostanme
|
57
|
+
# @param [String] target ip
|
58
|
+
def replace_host(comm, name, ip)
|
59
|
+
basename = name.split(".", 2)[0]
|
60
|
+
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
61
|
+
sed -i.bak '/#{name}/d' /etc/hosts
|
62
|
+
sed -i.bak '1i\\\n#{ip}\t#{name}\t#{basename}\n' /etc/hosts
|
63
|
+
EOH
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
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
|
@@ -0,0 +1,118 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Util
|
3
|
+
# Generic installation of content to shell config file
|
4
|
+
class InstallShellConfig
|
5
|
+
|
6
|
+
PERPEND_STRING = "# >>>> Vagrant command completion (start)".freeze
|
7
|
+
APPEND_STRING = "# <<<< Vagrant command completion (end)".freeze
|
8
|
+
|
9
|
+
attr_accessor :prepend_string
|
10
|
+
attr_accessor :string_insert
|
11
|
+
attr_accessor :append_string
|
12
|
+
attr_accessor :config_paths
|
13
|
+
|
14
|
+
def initialize(string_insert, config_paths)
|
15
|
+
@prepend_string = PERPEND_STRING
|
16
|
+
@string_insert = string_insert
|
17
|
+
@append_string = APPEND_STRING
|
18
|
+
@config_paths = config_paths
|
19
|
+
@logger = Log4r::Logger.new("vagrant::util::install_shell_config")
|
20
|
+
end
|
21
|
+
|
22
|
+
# Searches a users home dir for a shell config file based on a
|
23
|
+
# given home dir and a configured set of config paths. If there
|
24
|
+
# are multiple config paths, it will return the first match.
|
25
|
+
#
|
26
|
+
# @param [string] path to users home dir
|
27
|
+
# @return [string] path to shell config file if exists
|
28
|
+
def shell_installed(home)
|
29
|
+
@logger.info("Searching for config in home #{home}")
|
30
|
+
@config_paths.each do |path|
|
31
|
+
config_file = File.join(home, path)
|
32
|
+
if File.exists?(config_file)
|
33
|
+
@logger.info("Found config file #{config_file}")
|
34
|
+
return config_file
|
35
|
+
end
|
36
|
+
end
|
37
|
+
return nil
|
38
|
+
end
|
39
|
+
|
40
|
+
# Searches a given file for the existence of a set prepend string.
|
41
|
+
# This can be used to find if vagrant has inserted some strings to a file
|
42
|
+
#
|
43
|
+
# @param [string] path to a file (config file)
|
44
|
+
# @return [boolean] true if the prepend string is found in the file
|
45
|
+
def is_installed(path)
|
46
|
+
File.foreach(path) do |line|
|
47
|
+
if line.include?(@prepend_string)
|
48
|
+
@logger.info("Found completion already installed in #{path}")
|
49
|
+
return true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
return false
|
53
|
+
end
|
54
|
+
|
55
|
+
# Given a path to the users home dir, will install some given strings
|
56
|
+
# marked by a prepend and append string
|
57
|
+
#
|
58
|
+
# @param [string] path to users home dir
|
59
|
+
# @return [string] path to shell config file that was modified if exists
|
60
|
+
def install(home)
|
61
|
+
path = shell_installed(home)
|
62
|
+
if path && !is_installed(path)
|
63
|
+
File.open(path, "a") do |f|
|
64
|
+
f.write("\n")
|
65
|
+
f.write(@prepend_string)
|
66
|
+
f.write("\n")
|
67
|
+
f.write(@string_insert)
|
68
|
+
f.write("\n")
|
69
|
+
f.write(@append_string)
|
70
|
+
f.write("\n")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
return path
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Install autocomplete script to zsh config located as .zshrc
|
78
|
+
class InstallZSHShellConfig < InstallShellConfig
|
79
|
+
def initialize
|
80
|
+
string_insert = """fpath=(#{File.join(Vagrant.source_root, "contrib", "zsh")} $fpath)\ncompinit""".freeze
|
81
|
+
config_paths = [".zshrc".freeze].freeze
|
82
|
+
super(string_insert, config_paths)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# Install autocomplete script to bash config located as .bashrc or .bash_profile
|
87
|
+
class InstallBashShellConfig < InstallShellConfig
|
88
|
+
def initialize
|
89
|
+
string_insert = ". #{File.join(Vagrant.source_root, 'contrib', 'bash', 'completion.sh')}".freeze
|
90
|
+
config_paths = [".bashrc".freeze, ".bash_profile".freeze].freeze
|
91
|
+
super(string_insert, config_paths)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Install autocomplete script for supported shells
|
96
|
+
class InstallCLIAutocomplete
|
97
|
+
SUPPORTED_SHELLS = {
|
98
|
+
"zsh" => Vagrant::Util::InstallZSHShellConfig.new(),
|
99
|
+
"bash" => Vagrant::Util::InstallBashShellConfig.new()
|
100
|
+
}
|
101
|
+
|
102
|
+
def self.install(shells=[])
|
103
|
+
shells = SUPPORTED_SHELLS.keys() if shells.empty?
|
104
|
+
home = Dir.home
|
105
|
+
written_paths = []
|
106
|
+
|
107
|
+
shells.map do |shell|
|
108
|
+
if SUPPORTED_SHELLS[shell]
|
109
|
+
written_paths.push(SUPPORTED_SHELLS[shell].install(home))
|
110
|
+
else
|
111
|
+
raise ArgumentError, "shell must be in #{SUPPORTED_SHELLS.keys()}"
|
112
|
+
end
|
113
|
+
end.compact
|
114
|
+
return written_paths
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|