vagrant-unbundled 2.2.6.1 → 2.2.10.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 +153 -2
- data/README.md +5 -7
- 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 +736 -0
- data/contrib/zsh/generate_zsh_completion.rb +166 -0
- data/lib/vagrant.rb +25 -0
- data/lib/vagrant/action.rb +8 -0
- data/lib/vagrant/action/builder.rb +193 -38
- data/lib/vagrant/action/builtin/box_add.rb +15 -7
- 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 +127 -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 +10 -0
- data/lib/vagrant/action/builtin/trigger.rb +37 -0
- data/lib/vagrant/action/hook.rb +76 -23
- data/lib/vagrant/action/runner.rb +11 -26
- data/lib/vagrant/action/warden.rb +28 -22
- data/lib/vagrant/box.rb +5 -4
- data/lib/vagrant/box_metadata.rb +17 -3
- data/lib/vagrant/bundler.rb +265 -53
- data/lib/vagrant/cli.rb +4 -2
- data/lib/vagrant/errors.rb +61 -1
- data/lib/vagrant/machine.rb +56 -6
- data/lib/vagrant/machine_index.rb +27 -1
- data/lib/vagrant/plugin/manager.rb +25 -14
- data/lib/vagrant/plugin/v2/command.rb +6 -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 +28 -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 +7 -3
- 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/network_ip.rb +11 -1
- data/lib/vagrant/util/numeric.rb +69 -0
- data/lib/vagrant/util/platform.rb +8 -1
- data/lib/vagrant/util/powershell.rb +1 -1
- data/lib/vagrant/util/subprocess.rb +9 -1
- 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/cloud/locales/en.yml +1 -1
- data/plugins/commands/cloud/publish.rb +1 -1
- data/plugins/commands/destroy/command.rb +6 -2
- 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/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/mount_vmware_shared_folder.rb +99 -13
- data/plugins/guests/darwin/plugin.rb +5 -0
- data/plugins/guests/debian/cap/change_host_name.rb +11 -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 +16 -0
- data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +4 -11
- data/plugins/guests/linux/cap/persist_mount_shared_folder.rb +62 -0
- data/plugins/guests/linux/cap/reboot.rb +48 -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 +10 -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 +13 -12
- data/plugins/guests/windows/cap/public_key.rb +3 -3
- data/plugins/guests/windows/cap/reboot.rb +2 -1
- 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 +126 -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 +225 -11
- 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 +2 -0
- 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 +100 -0
- data/plugins/providers/virtualbox/plugin.rb +38 -0
- 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 +36 -0
- data/plugins/synced_folders/smb/plugin.rb +10 -0
- data/plugins/synced_folders/smb/synced_folder.rb +2 -2
- data/plugins/synced_folders/unix_mount_helpers.rb +14 -0
- 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 +12 -12
- data/version.txt +1 -1
- metadata +3937 -3686
- 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
@@ -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,6 +434,7 @@ 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
439
|
Util::Downloader.new(url, temp_path, downloader_options)
|
432
440
|
end
|
@@ -488,7 +496,7 @@ module Vagrant
|
|
488
496
|
url ||= uri.opaque
|
489
497
|
#7570 Strip leading slash left in front of drive letter by uri.path
|
490
498
|
Util::Platform.windows? && url.gsub!(/^\/([a-zA-Z]:)/, '\1')
|
491
|
-
url =
|
499
|
+
url = @parser.unescape(url)
|
492
500
|
|
493
501
|
begin
|
494
502
|
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,127 @@
|
|
1
|
+
require '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 [MIME::Text] 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 [MIME::Text] 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
|
+
# Note: content_type must remove the leading `text/` because
|
59
|
+
# the MIME::Text initializer hardcodes `text/` already to the type.
|
60
|
+
# We assume content_type is correct due to the validation step
|
61
|
+
# in VagrantConfigCloudInit.
|
62
|
+
content_type = cfg.content_type.split('/', 2).last
|
63
|
+
text_msg = MIME::Text.new(text, content_type)
|
64
|
+
|
65
|
+
text_msg
|
66
|
+
end
|
67
|
+
|
68
|
+
# Combines all known cloud_init configs into a multipart mixed MIME text
|
69
|
+
# message
|
70
|
+
#
|
71
|
+
# @param [Vagrant::Machine] machine
|
72
|
+
# @param [Array<MIME::Text>] text_msg - One or more text configs
|
73
|
+
# @return [MIME::Multipart::Mixed] msg
|
74
|
+
def generate_cfg_msg(machine, text_cfgs)
|
75
|
+
msg = MIME::Multipart::Mixed.new
|
76
|
+
msg.headers.set("MIME-Version", "1.0")
|
77
|
+
|
78
|
+
text_cfgs.each do |c|
|
79
|
+
msg.add(c)
|
80
|
+
end
|
81
|
+
|
82
|
+
msg
|
83
|
+
end
|
84
|
+
|
85
|
+
# Writes the contents of the guests cloud_init config to a tmp
|
86
|
+
# dir and passes that source directory along to the host cap to be
|
87
|
+
# written to an iso
|
88
|
+
#
|
89
|
+
# @param [Vagrant::Machine] machine
|
90
|
+
# @param [MIME::Multipart::Mixed] user_data
|
91
|
+
# @param [Hash] meta_data
|
92
|
+
def write_cfg_iso(machine, env, user_data, meta_data)
|
93
|
+
iso_path = nil
|
94
|
+
|
95
|
+
if env[:env].host.capability?(:create_iso)
|
96
|
+
begin
|
97
|
+
source_dir = Pathname.new(Dir.mktmpdir(TEMP_PREFIX))
|
98
|
+
File.open("#{source_dir}/user-data", 'w') { |file| file.write(user_data.to_s) }
|
99
|
+
|
100
|
+
File.open("#{source_dir}/meta-data", 'w') { |file| file.write(meta_data.to_yaml) }
|
101
|
+
|
102
|
+
iso_path = env[:env].host.capability(:create_iso,
|
103
|
+
source_dir, volume_id: "cidata")
|
104
|
+
attach_disk_config(machine, env, iso_path.to_path)
|
105
|
+
ensure
|
106
|
+
FileUtils.remove_entry(source_dir)
|
107
|
+
end
|
108
|
+
else
|
109
|
+
raise Errors::CreateIsoHostCapNotFound
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Adds a new :dvd disk config with the given iso_path to be attached
|
114
|
+
# to the guest later
|
115
|
+
#
|
116
|
+
# @param [Vagrant::Machine] machine
|
117
|
+
# @param [Vagrant::Environment] env
|
118
|
+
# @param [String] iso_path
|
119
|
+
def attach_disk_config(machine, env, iso_path)
|
120
|
+
@logger.info("Adding cloud_init iso '#{iso_path}' to disk config")
|
121
|
+
machine.config.vm.disk :dvd, file: iso_path, name: "vagrant-cloud_init-disk"
|
122
|
+
machine.config.vm.disks.each { |d| d.finalize! if d.type == :dvd && d.file == iso_path }
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
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!
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require "set"
|
2
2
|
|
3
3
|
require "log4r"
|
4
|
+
require "socket"
|
4
5
|
|
5
6
|
require "vagrant/util/is_port_open"
|
7
|
+
require "vagrant/util/ipv4_interfaces"
|
6
8
|
|
7
9
|
module Vagrant
|
8
10
|
module Action
|
@@ -25,6 +27,7 @@ module Vagrant
|
|
25
27
|
#
|
26
28
|
class HandleForwardedPortCollisions
|
27
29
|
include Util::IsPortOpen
|
30
|
+
include Util::IPv4Interfaces
|
28
31
|
|
29
32
|
def initialize(app, env)
|
30
33
|
@app = app
|
@@ -120,6 +123,7 @@ module Vagrant
|
|
120
123
|
in_use = is_forwarded_already(extra_in_use, host_port, host_ip) ||
|
121
124
|
call_port_checker(port_checker, host_ip, host_port) ||
|
122
125
|
lease_check(host_ip, host_port)
|
126
|
+
|
123
127
|
if in_use
|
124
128
|
if !repair || !options[:auto_correct]
|
125
129
|
raise Errors::ForwardPortCollision,
|
@@ -243,18 +247,33 @@ module Vagrant
|
|
243
247
|
end
|
244
248
|
|
245
249
|
def port_check(host_ip, host_port)
|
246
|
-
|
247
|
-
|
250
|
+
self.class.port_check(@machine, host_ip, host_port)
|
251
|
+
end
|
252
|
+
|
253
|
+
def self.port_check(machine, host_ip, host_port)
|
254
|
+
@logger = Log4r::Logger.new("vagrant::action::builtin::handle_port_collisions")
|
255
|
+
# If no host_ip is specified, intention taken to be listen on all interfaces.
|
248
256
|
test_host_ip = host_ip || "0.0.0.0"
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
257
|
+
if Util::Platform.windows? && test_host_ip == "0.0.0.0"
|
258
|
+
@logger.debug("Testing port #{host_port} on all IPv4 interfaces...")
|
259
|
+
available_interfaces = Vagrant::Util::IPv4Interfaces.ipv4_interfaces.select do |interface|
|
260
|
+
@logger.debug("Testing #{interface[0]} with IP address #{interface[1]}")
|
261
|
+
!Vagrant::Util::IsPortOpen.is_port_open?(interface[1], host_port)
|
262
|
+
end
|
263
|
+
if available_interfaces.empty?
|
264
|
+
@logger.debug("Cannot forward port #{host_port} on any interfaces.")
|
265
|
+
true
|
255
266
|
else
|
256
|
-
|
267
|
+
@logger.debug("Port #{host_port} will forward to the guest on the following interfaces: #{available_interfaces}")
|
268
|
+
false
|
269
|
+
end
|
270
|
+
else
|
271
|
+
# Do a regular check
|
272
|
+
if test_host_ip != "0.0.0.0" && !Addrinfo.ip(test_host_ip).ipv4_loopback? &&
|
273
|
+
Vagrant::Util::IPv4Interfaces.ipv4_interfaces.none? { |iface| iface[1] == test_host_ip }
|
274
|
+
@logger.warn("host IP address is not local to this device host_ip=#{test_host_ip}")
|
257
275
|
end
|
276
|
+
Vagrant::Util::IsPortOpen.is_port_open?(test_host_ip, host_port)
|
258
277
|
end
|
259
278
|
end
|
260
279
|
|