vagrant-unbundled 2.2.6.2 → 2.2.14.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 +213 -2
- data/Gemfile +1 -1
- data/README.md +9 -51
- data/RELEASE.md +1 -1
- data/bin/vagrant +23 -0
- data/contrib/README.md +1 -0
- data/contrib/bash/completion.sh +13 -1
- 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 +25 -4
- data/lib/vagrant/action.rb +8 -0
- data/lib/vagrant/action/builder.rb +184 -38
- data/lib/vagrant/action/builtin/box_add.rb +20 -8
- 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/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 +52 -0
- 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 +20 -1
- 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/ssh_run.rb +21 -3
- 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 -22
- data/lib/vagrant/box.rb +11 -4
- data/lib/vagrant/box_collection.rb +1 -1
- data/lib/vagrant/box_metadata.rb +17 -3
- data/lib/vagrant/bundler.rb +298 -59
- data/lib/vagrant/cli.rb +4 -2
- data/lib/vagrant/errors.rb +61 -1
- data/lib/vagrant/machine.rb +64 -11
- data/lib/vagrant/machine_index.rb +28 -1
- data/lib/vagrant/plugin/manager.rb +25 -14
- 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 +51 -5
- data/lib/vagrant/util.rb +1 -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 +8 -5
- data/lib/vagrant/util/directory.rb +19 -0
- data/lib/vagrant/util/downloader.rb +10 -5
- data/lib/vagrant/util/file_checksum.rb +6 -2
- 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 -20
- 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 +69 -0
- data/lib/vagrant/util/platform.rb +10 -2
- data/lib/vagrant/util/powershell.rb +1 -1
- 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 +1 -1
- 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/box/command/outdated.rb +14 -2
- 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_downloader_authentication.rb +57 -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 +50 -81
- data/plugins/commands/cloud/list.rb +3 -4
- data/plugins/commands/cloud/locales/en.yml +10 -10
- 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 +44 -34
- data/plugins/commands/cloud/publish.rb +185 -108
- data/plugins/commands/cloud/search.rb +34 -21
- data/plugins/commands/cloud/util.rb +266 -162
- 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 +6 -2
- data/plugins/commands/login/plugin.rb +0 -13
- data/plugins/commands/snapshot/command/save.rb +13 -8
- 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/rsync.rb +1 -1
- data/plugins/guests/alpine/plugin.rb +16 -0
- 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 +109 -13
- 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/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 +75 -0
- data/plugins/guests/linux/cap/reboot.rb +53 -0
- data/plugins/guests/linux/plugin.rb +20 -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/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/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/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/cap/nfs.rb +11 -0
- data/plugins/hosts/darwin/plugin.rb +15 -0
- data/plugins/hosts/linux/cap/fs_iso.rb +49 -0
- data/plugins/hosts/linux/cap/nfs.rb +21 -2
- 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 +221 -0
- data/plugins/kernel_v2/config/ssh_connect.rb +24 -0
- data/plugins/kernel_v2/config/vm.rb +230 -15
- data/plugins/kernel_v2/config/vm_provisioner.rb +17 -3
- 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 +73 -10
- data/plugins/providers/docker/errors.rb +4 -0
- data/plugins/providers/docker/executor/local.rb +7 -1
- 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 +14 -1
- 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/forward_ports.rb +2 -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 +85 -0
- data/plugins/providers/virtualbox/cap/configure_disks.rb +440 -0
- data/plugins/providers/virtualbox/cap/mount_options.rb +35 -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 +17 -2
- data/plugins/providers/virtualbox/driver/version_5_0.rb +217 -2
- data/plugins/providers/virtualbox/driver/version_6_1.rb +39 -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 +38 -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/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 +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.erb +1 -1
- 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/locales/en.yml +235 -6
- data/templates/locales/providers_docker.yml +6 -0
- data/templates/nfs/exports_darwin.erb +7 -0
- data/vagrant.gemspec +14 -15
- data/version.txt +1 -1
- metadata +3577 -3855
- 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
@@ -25,6 +25,7 @@ module Vagrant
|
|
25
25
|
def initialize(app, env)
|
26
26
|
@app = app
|
27
27
|
@logger = Log4r::Logger.new("vagrant::action::builtin::box_add")
|
28
|
+
@parser = URI::RFC2396_Parser.new
|
28
29
|
end
|
29
30
|
|
30
31
|
def call(env)
|
@@ -44,7 +45,7 @@ module Vagrant
|
|
44
45
|
u = u.gsub("\\", "/")
|
45
46
|
if Util::Platform.windows? && u =~ /^[a-z]:/i
|
46
47
|
# On Windows, we need to be careful about drive letters
|
47
|
-
u = "file:///#{
|
48
|
+
u = "file:///#{@parser.escape(u)}"
|
48
49
|
end
|
49
50
|
|
50
51
|
if u =~ /^[a-z0-9]+:.*$/i && !u.start_with?("file://")
|
@@ -53,9 +54,9 @@ module Vagrant
|
|
53
54
|
end
|
54
55
|
|
55
56
|
# Expand the path and try to use that, if possible
|
56
|
-
p = File.expand_path(
|
57
|
+
p = File.expand_path(@parser.unescape(u.gsub(/^file:\/\//, "")))
|
57
58
|
p = Util::Platform.cygwin_windows_path(p)
|
58
|
-
next "file://#{
|
59
|
+
next "file://#{@parser.escape(p.gsub("\\", "/"))}" if File.file?(p)
|
59
60
|
|
60
61
|
u
|
61
62
|
end
|
@@ -348,9 +349,15 @@ module Vagrant
|
|
348
349
|
end
|
349
350
|
|
350
351
|
if opts[:checksum] && opts[:checksum_type]
|
351
|
-
|
352
|
-
|
353
|
-
|
352
|
+
if opts[:checksum].to_s.strip.empty?
|
353
|
+
@logger.warn("Given checksum is empty, cannot validate checksum for box")
|
354
|
+
elsif opts[:checksum_type].to_s.strip.empty?
|
355
|
+
@logger.warn("Given checksum type is empty, cannot validate checksum for box")
|
356
|
+
else
|
357
|
+
env[:ui].detail(I18n.t("vagrant.actions.box.add.checksumming"))
|
358
|
+
validate_checksum(
|
359
|
+
opts[:checksum_type], opts[:checksum], box_url)
|
360
|
+
end
|
354
361
|
end
|
355
362
|
|
356
363
|
# Add the box!
|
@@ -427,14 +434,18 @@ module Vagrant
|
|
427
434
|
downloader_options[:headers] = ["Accept: application/json"] if opts[:json]
|
428
435
|
downloader_options[:ui] = env[:ui] if opts[:ui]
|
429
436
|
downloader_options[:location_trusted] = env[:box_download_location_trusted]
|
437
|
+
downloader_options[:box_extra_download_options] = env[:box_extra_download_options]
|
430
438
|
|
431
|
-
Util::Downloader.new(url, temp_path, downloader_options)
|
439
|
+
d = Util::Downloader.new(url, temp_path, downloader_options)
|
440
|
+
env[:hook].call(:authenticate_box_downloader, downloader: d)
|
441
|
+
d
|
432
442
|
end
|
433
443
|
|
434
444
|
def download(url, env, **opts)
|
435
445
|
opts[:ui] = true if !opts.key?(:ui)
|
436
446
|
|
437
447
|
d = downloader(url, env, **opts)
|
448
|
+
env[:hook].call(:authenticate_box_downloader, downloader: d)
|
438
449
|
|
439
450
|
# Download the box to a temporary path. We store the temporary
|
440
451
|
# path as an instance variable so that the `#recover` method can
|
@@ -478,6 +489,7 @@ module Vagrant
|
|
478
489
|
# @return [Boolean] true if metadata
|
479
490
|
def metadata_url?(url, env)
|
480
491
|
d = downloader(url, env, json: true, ui: false)
|
492
|
+
env[:hook].call(:authenticate_box_downloader, downloader: d)
|
481
493
|
|
482
494
|
# If we're downloading a file, cURL just returns no
|
483
495
|
# content-type (makes sense), so we just test if it is JSON
|
@@ -488,7 +500,7 @@ module Vagrant
|
|
488
500
|
url ||= uri.opaque
|
489
501
|
#7570 Strip leading slash left in front of drive letter by uri.path
|
490
502
|
Util::Platform.windows? && url.gsub!(/^\/([a-zA-Z]:)/, '\1')
|
491
|
-
url =
|
503
|
+
url = @parser.unescape(url)
|
492
504
|
|
493
505
|
begin
|
494
506
|
File.open(url, "r") do |f|
|
@@ -40,7 +40,7 @@ module Vagrant
|
|
40
40
|
# Have download options specified in the environment override
|
41
41
|
# options specified for the machine.
|
42
42
|
download_options = {
|
43
|
-
automatic_check:
|
43
|
+
automatic_check: !env[:box_outdated_force],
|
44
44
|
ca_cert: env[:ca_cert] || machine.config.vm.box_download_ca_cert,
|
45
45
|
ca_path: env[:ca_path] || machine.config.vm.box_download_ca_path,
|
46
46
|
client_cert: env[:client_cert] ||
|
@@ -70,15 +70,23 @@ module Vagrant
|
|
70
70
|
message: e.message))
|
71
71
|
end
|
72
72
|
env[:box_outdated] = update != nil
|
73
|
-
|
73
|
+
local_update = check_outdated_local(env)
|
74
|
+
if update && (local_update.nil? || (local_update.version < update[1].version))
|
74
75
|
env[:ui].warn(I18n.t(
|
75
76
|
"vagrant.box_outdated_single",
|
76
77
|
name: update[0].name,
|
77
78
|
provider: box.provider,
|
78
79
|
current: box.version,
|
79
80
|
latest: update[1].version))
|
81
|
+
elsif local_update
|
82
|
+
env[:ui].warn(I18n.t(
|
83
|
+
"vagrant.box_outdated_local",
|
84
|
+
name: local_update.name,
|
85
|
+
old: box.version,
|
86
|
+
new: local_update.version))
|
87
|
+
env[:box_outdated] = true
|
80
88
|
else
|
81
|
-
|
89
|
+
env[:box_outdated] = false
|
82
90
|
end
|
83
91
|
|
84
92
|
@app.call(env)
|
@@ -93,19 +101,8 @@ module Vagrant
|
|
93
101
|
version ||= ""
|
94
102
|
version += "> #{machine.box.version}"
|
95
103
|
|
96
|
-
|
104
|
+
env[:box_collection].find(
|
97
105
|
machine.box.name, machine.box.provider, version)
|
98
|
-
if box
|
99
|
-
env[:ui].warn(I18n.t(
|
100
|
-
"vagrant.box_outdated_local",
|
101
|
-
name: box.name,
|
102
|
-
old: machine.box.version,
|
103
|
-
new: box.version))
|
104
|
-
env[:box_outdated] = true
|
105
|
-
return
|
106
|
-
end
|
107
|
-
|
108
|
-
env[:box_outdated] = false
|
109
106
|
end
|
110
107
|
end
|
111
108
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Action
|
5
|
+
module Builtin
|
6
|
+
class CleanupDisks
|
7
|
+
# Removes any attached disks no longer defined in a Vagrantfile config
|
8
|
+
def initialize(app, env)
|
9
|
+
@app = app
|
10
|
+
@logger = Log4r::Logger.new("vagrant::action::builtin::disk")
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
machine = env[:machine]
|
15
|
+
defined_disks = get_disks(machine, env)
|
16
|
+
|
17
|
+
# Call into providers machine implementation for disk management
|
18
|
+
disk_meta_file = read_disk_metadata(machine)
|
19
|
+
|
20
|
+
if !disk_meta_file.empty?
|
21
|
+
if machine.provider.capability?(:cleanup_disks)
|
22
|
+
machine.provider.capability(:cleanup_disks, defined_disks, disk_meta_file)
|
23
|
+
else
|
24
|
+
env[:ui].warn(I18n.t("vagrant.actions.disk.provider_unsupported",
|
25
|
+
provider: machine.provider_name))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Continue On
|
30
|
+
@app.call(env)
|
31
|
+
end
|
32
|
+
|
33
|
+
def read_disk_metadata(machine)
|
34
|
+
meta_file = machine.data_dir.join("disk_meta")
|
35
|
+
if File.file?(meta_file)
|
36
|
+
disk_meta = JSON.parse(meta_file.read)
|
37
|
+
else
|
38
|
+
@logger.info("No previous disk_meta file defined for guest #{machine.name}")
|
39
|
+
disk_meta = {}
|
40
|
+
end
|
41
|
+
|
42
|
+
return disk_meta
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_disks(machine, env)
|
46
|
+
return @_disks if @_disks
|
47
|
+
|
48
|
+
@_disks = []
|
49
|
+
@_disks = machine.config.vm.disks
|
50
|
+
|
51
|
+
@_disks
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'vagrant/util/mime'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
module Vagrant
|
5
|
+
module Action
|
6
|
+
module Builtin
|
7
|
+
class CloudInitSetup
|
8
|
+
TEMP_PREFIX = "vagrant-cloud-init-iso-temp-".freeze
|
9
|
+
|
10
|
+
def initialize(app, env)
|
11
|
+
@app = app
|
12
|
+
@logger = Log4r::Logger.new("vagrant::action::builtin::cloudinit::setup")
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(env)
|
16
|
+
machine = env[:machine]
|
17
|
+
|
18
|
+
user_data_configs = machine.config.vm.cloud_init_configs
|
19
|
+
.select { |c| c.type == :user_data }
|
20
|
+
|
21
|
+
if !user_data_configs.empty?
|
22
|
+
user_data = setup_user_data(machine, env, user_data_configs)
|
23
|
+
meta_data = { "instance-id" => "i-#{machine.id.split('-').join}" }
|
24
|
+
|
25
|
+
write_cfg_iso(machine, env, user_data, meta_data)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Continue On
|
29
|
+
@app.call(env)
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param [Vagrant::Machine] machine
|
33
|
+
# @param [Vagrant::Environment] env
|
34
|
+
# @param [Array<#VagrantPlugins::Kernel_V2::VagrantConfigCloudInit>] user_data_cfgs
|
35
|
+
# @return [Vagrant::Util::Mime::MultiPart] user_data
|
36
|
+
def setup_user_data(machine, env, user_data_cfgs)
|
37
|
+
machine.ui.info(I18n.t("vagrant.actions.vm.cloud_init_user_data_setup"))
|
38
|
+
|
39
|
+
text_cfgs = user_data_cfgs.map { |cfg| read_text_cfg(machine, cfg) }
|
40
|
+
|
41
|
+
user_data = generate_cfg_msg(machine, text_cfgs)
|
42
|
+
user_data
|
43
|
+
end
|
44
|
+
|
45
|
+
# Reads an individual cloud_init config and stores its contents and the
|
46
|
+
# content_type as a MIME text
|
47
|
+
#
|
48
|
+
# @param [Vagrant::Machine] machine
|
49
|
+
# @param [VagrantPlugins::Kernel_V2::VagrantConfigCloudInit] cfg
|
50
|
+
# @return [Vagrant::Util::Mime::Entity] text_msg
|
51
|
+
def read_text_cfg(machine, cfg)
|
52
|
+
if cfg.path
|
53
|
+
text = File.read(Pathname.new(cfg.path).expand_path(machine.env.root_path))
|
54
|
+
else
|
55
|
+
text = cfg.inline
|
56
|
+
end
|
57
|
+
|
58
|
+
text_msg = Vagrant::Util::Mime::Entity.new(text, cfg.content_type)
|
59
|
+
text_msg.disposition = "attachment; filename=\"#{File.basename(cfg.content_disposition_filename).gsub('"', '\"')}\"" if cfg.content_disposition_filename
|
60
|
+
text_msg
|
61
|
+
end
|
62
|
+
|
63
|
+
# Combines all known cloud_init configs into a multipart mixed MIME text
|
64
|
+
# message
|
65
|
+
#
|
66
|
+
# @param [Vagrant::Machine] machine
|
67
|
+
# @param [Array<Vagrant::Util::Mime::Entity>] text_msg - One or more text configs
|
68
|
+
# @return [Vagrant::Util::Mime::Multipart] msg
|
69
|
+
def generate_cfg_msg(machine, text_cfgs)
|
70
|
+
msg = Vagrant::Util::Mime::Multipart.new
|
71
|
+
msg.headers["MIME-Version"] = "1.0"
|
72
|
+
|
73
|
+
text_cfgs.each do |c|
|
74
|
+
msg.add(c)
|
75
|
+
end
|
76
|
+
|
77
|
+
msg
|
78
|
+
end
|
79
|
+
|
80
|
+
# Writes the contents of the guests cloud_init config to a tmp
|
81
|
+
# dir and passes that source directory along to the host cap to be
|
82
|
+
# written to an iso
|
83
|
+
#
|
84
|
+
# @param [Vagrant::Machine] machine
|
85
|
+
# @param [Vagrant::Util::Mime::Multipart] user_data
|
86
|
+
# @param [Hash] meta_data
|
87
|
+
def write_cfg_iso(machine, env, user_data, meta_data)
|
88
|
+
iso_path = nil
|
89
|
+
|
90
|
+
if env[:env].host.capability?(:create_iso)
|
91
|
+
begin
|
92
|
+
source_dir = Pathname.new(Dir.mktmpdir(TEMP_PREFIX))
|
93
|
+
File.open("#{source_dir}/user-data", 'w') { |file| file.write(user_data.to_s) }
|
94
|
+
|
95
|
+
File.open("#{source_dir}/meta-data", 'w') { |file| file.write(meta_data.to_yaml) }
|
96
|
+
|
97
|
+
iso_path = env[:env].host.capability(:create_iso,
|
98
|
+
source_dir, volume_id: "cidata")
|
99
|
+
attach_disk_config(machine, env, iso_path.to_path)
|
100
|
+
ensure
|
101
|
+
FileUtils.remove_entry(source_dir)
|
102
|
+
end
|
103
|
+
else
|
104
|
+
raise Errors::CreateIsoHostCapNotFound
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Adds a new :dvd disk config with the given iso_path to be attached
|
109
|
+
# to the guest later
|
110
|
+
#
|
111
|
+
# @param [Vagrant::Machine] machine
|
112
|
+
# @param [Vagrant::Environment] env
|
113
|
+
# @param [String] iso_path
|
114
|
+
def attach_disk_config(machine, env, iso_path)
|
115
|
+
@logger.info("Adding cloud_init iso '#{iso_path}' to disk config")
|
116
|
+
machine.config.vm.disk :dvd, file: iso_path, name: "vagrant-cloud_init-disk"
|
117
|
+
machine.config.vm.disks.each { |d| d.finalize! if d.type == :dvd && d.file == iso_path }
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Action
|
3
|
+
module Builtin
|
4
|
+
class CloudInitWait
|
5
|
+
|
6
|
+
def initialize(app, env)
|
7
|
+
@app = app
|
8
|
+
@logger = Log4r::Logger.new("vagrant::action::builtin::cloudinitwait")
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
machine = env[:machine]
|
13
|
+
cloud_init_wait_cmd = "cloud-init status --wait"
|
14
|
+
if !machine.config.vm.cloud_init_configs.empty?
|
15
|
+
if machine.communicate.test("command -v cloud-init")
|
16
|
+
env[:ui].output(I18n.t("vagrant.cloud_init_waiting"))
|
17
|
+
result = machine.communicate.sudo(cloud_init_wait_cmd, error_check: false)
|
18
|
+
if result != 0
|
19
|
+
raise Vagrant::Errors::CloudInitCommandFailed, cmd: cloud_init_wait_cmd, guest_name: machine.name
|
20
|
+
end
|
21
|
+
else
|
22
|
+
raise Vagrant::Errors::CloudInitNotFound, guest_name: machine.name
|
23
|
+
end
|
24
|
+
end
|
25
|
+
@app.call(env)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Action
|
3
|
+
module Builtin
|
4
|
+
# This class is used to delay execution until the end of
|
5
|
+
# a configured stack
|
6
|
+
class Delayed
|
7
|
+
# @param [Object] callable The object to call (must respond to #call)
|
8
|
+
def initialize(app, env, callable)
|
9
|
+
if !callable.respond_to?(:call)
|
10
|
+
raise TypeError, "Callable argument is expected to respond to `#call`"
|
11
|
+
end
|
12
|
+
@app = app
|
13
|
+
@env = env
|
14
|
+
@callable = callable
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
# Allow the rest of the call stack to execute
|
19
|
+
@app.call(env)
|
20
|
+
# Now call our delayed stack
|
21
|
+
@callable.call(env)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "json"
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Action
|
5
|
+
module Builtin
|
6
|
+
class Disk
|
7
|
+
def initialize(app, env)
|
8
|
+
@app = app
|
9
|
+
@logger = Log4r::Logger.new("vagrant::action::builtin::disk")
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
machine = env[:machine]
|
14
|
+
defined_disks = get_disks(machine, env)
|
15
|
+
|
16
|
+
# Call into providers machine implementation for disk management
|
17
|
+
configured_disks = {}
|
18
|
+
if !defined_disks.empty?
|
19
|
+
if machine.provider.capability?(:configure_disks)
|
20
|
+
configured_disks = machine.provider.capability(:configure_disks, defined_disks)
|
21
|
+
else
|
22
|
+
env[:ui].warn(I18n.t("vagrant.actions.disk.provider_unsupported",
|
23
|
+
provider: machine.provider_name))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
write_disk_metadata(machine, configured_disks) unless configured_disks.empty?
|
28
|
+
|
29
|
+
# Continue On
|
30
|
+
@app.call(env)
|
31
|
+
end
|
32
|
+
|
33
|
+
def write_disk_metadata(machine, current_disks)
|
34
|
+
meta_file = machine.data_dir.join("disk_meta")
|
35
|
+
@logger.debug("Writing disk metadata file to #{meta_file}")
|
36
|
+
File.open(meta_file.to_s, "w+") do |file|
|
37
|
+
file.write(JSON.dump(current_disks))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_disks(machine, env)
|
42
|
+
return @_disks if @_disks
|
43
|
+
|
44
|
+
@_disks = []
|
45
|
+
@_disks = machine.config.vm.disks
|
46
|
+
|
47
|
+
@_disks
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -20,7 +20,7 @@ module Vagrant
|
|
20
20
|
def call(env)
|
21
21
|
machine = env[:machine]
|
22
22
|
|
23
|
-
if !machine.config.vm.box
|
23
|
+
if !machine.config.vm.box || machine.config.vm.box.to_s.empty?
|
24
24
|
@logger.info("Skipping HandleBox because no box is set")
|
25
25
|
return @app.call(env)
|
26
26
|
end
|
@@ -67,6 +67,7 @@ module Vagrant
|
|
67
67
|
box_download_checksum_type = machine.config.vm.box_download_checksum_type
|
68
68
|
box_download_checksum = machine.config.vm.box_download_checksum
|
69
69
|
box_download_location_trusted = machine.config.vm.box_download_location_trusted
|
70
|
+
box_extra_download_options = machine.config.vm.box_extra_download_options
|
70
71
|
box_formats = machine.provider_options[:box_format] ||
|
71
72
|
machine.provider_name
|
72
73
|
|
@@ -92,6 +93,7 @@ module Vagrant
|
|
92
93
|
box_checksum_type: box_download_checksum_type,
|
93
94
|
box_checksum: box_download_checksum,
|
94
95
|
box_download_location_trusted: box_download_location_trusted,
|
96
|
+
box_extra_download_options: box_extra_download_options,
|
95
97
|
}))
|
96
98
|
rescue Errors::BoxAlreadyExists
|
97
99
|
# Just ignore this, since it means the next part will succeed!
|