vagrant-unbundled 2.2.6.0 → 2.2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hashibot.hcl +14 -0
- data/CHANGELOG.md +93 -2
- data/README.md +1 -3
- data/bin/vagrant +23 -0
- data/contrib/bash/completion.sh +13 -1
- data/lib/vagrant.rb +25 -0
- data/lib/vagrant/action.rb +5 -0
- data/lib/vagrant/action/builder.rb +145 -24
- data/lib/vagrant/action/builtin/box_add.rb +11 -4
- data/lib/vagrant/action/builtin/box_check_outdated.rb +12 -15
- data/lib/vagrant/action/builtin/cleanup_disks.rb +56 -0
- data/lib/vagrant/action/builtin/delayed.rb +26 -0
- data/lib/vagrant/action/builtin/disk.rb +52 -0
- data/lib/vagrant/action/builtin/handle_box.rb +2 -0
- data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +28 -9
- data/lib/vagrant/action/builtin/mixin_provisioners.rb +19 -1
- data/lib/vagrant/action/builtin/ssh_run.rb +21 -3
- data/lib/vagrant/action/builtin/trigger.rb +36 -0
- data/lib/vagrant/action/hook.rb +20 -2
- data/lib/vagrant/action/runner.rb +11 -26
- data/lib/vagrant/action/warden.rb +4 -18
- data/lib/vagrant/box_metadata.rb +17 -3
- data/lib/vagrant/bundler.rb +260 -53
- data/lib/vagrant/cli.rb +4 -2
- data/lib/vagrant/errors.rb +24 -0
- data/lib/vagrant/machine.rb +9 -6
- data/lib/vagrant/plugin/manager.rb +25 -14
- data/lib/vagrant/plugin/v2/command.rb +1 -1
- data/lib/vagrant/plugin/v2/manager.rb +53 -0
- data/lib/vagrant/plugin/v2/plugin.rb +1 -0
- data/lib/vagrant/plugin/v2/trigger.rb +64 -26
- data/lib/vagrant/shared_helpers.rb +28 -0
- data/lib/vagrant/ui.rb +50 -4
- data/lib/vagrant/util.rb +1 -0
- data/lib/vagrant/util/curl_helper.rb +8 -5
- data/lib/vagrant/util/downloader.rb +5 -1
- data/lib/vagrant/util/file_checksum.rb +6 -2
- data/lib/vagrant/util/guest_inspection.rb +9 -1
- data/lib/vagrant/util/io.rb +7 -27
- data/lib/vagrant/util/is_port_open.rb +1 -2
- data/lib/vagrant/util/map_command_options.rb +33 -0
- data/lib/vagrant/util/numeric.rb +69 -0
- data/lib/vagrant/util/platform.rb +8 -1
- data/plugins/commands/box/command/outdated.rb +14 -2
- data/plugins/commands/cloud/locales/en.yml +1 -1
- data/plugins/commands/cloud/publish.rb +1 -1
- data/plugins/commands/snapshot/command/save.rb +13 -8
- data/plugins/commands/ssh_config/command.rb +1 -1
- data/plugins/communicators/ssh/communicator.rb +18 -23
- data/plugins/communicators/winrm/config.rb +1 -1
- data/plugins/communicators/winrm/shell.rb +1 -1
- data/plugins/communicators/winssh/communicator.rb +126 -38
- data/plugins/communicators/winssh/config.rb +3 -7
- data/plugins/guests/alpine/cap/rsync.rb +1 -1
- data/plugins/guests/alpine/plugin.rb +16 -0
- data/plugins/guests/centos/cap/flavor.rb +24 -0
- data/plugins/guests/centos/guest.rb +9 -0
- data/plugins/guests/centos/plugin.rb +20 -0
- data/plugins/guests/darwin/cap/mount_vmware_shared_folder.rb +99 -13
- data/plugins/guests/darwin/plugin.rb +5 -0
- data/plugins/guests/debian/cap/configure_networks.rb +14 -6
- data/plugins/guests/linux/cap/halt.rb +9 -1
- data/plugins/guests/linux/cap/mount_smb_shared_folder.rb +16 -0
- data/plugins/guests/linux/cap/reboot.rb +48 -0
- data/plugins/guests/linux/plugin.rb +10 -0
- data/plugins/guests/redhat/cap/flavor.rb +3 -1
- data/plugins/guests/redhat/cap/nfs_client.rb +2 -2
- data/plugins/guests/redhat/cap/smb.rb +20 -0
- data/plugins/guests/redhat/plugin.rb +5 -0
- data/plugins/guests/suse/cap/change_host_name.rb +2 -2
- data/plugins/guests/windows/cap/public_key.rb +3 -3
- data/plugins/guests/windows/cap/reboot.rb +2 -1
- data/plugins/hosts/darwin/cap/nfs.rb +11 -0
- data/plugins/hosts/darwin/plugin.rb +5 -0
- data/plugins/hosts/linux/cap/nfs.rb +21 -2
- data/plugins/kernel_v2/config/disk.rb +199 -0
- data/plugins/kernel_v2/config/ssh_connect.rb +24 -0
- data/plugins/kernel_v2/config/vm.rb +109 -4
- data/plugins/kernel_v2/config/vm_provisioner.rb +4 -1
- data/plugins/kernel_v2/config/vm_trigger.rb +2 -5
- data/plugins/providers/docker/driver.rb +38 -10
- data/plugins/providers/docker/errors.rb +4 -0
- data/plugins/providers/docker/executor/local.rb +7 -1
- data/plugins/providers/hyperv/action/export.rb +4 -2
- data/plugins/providers/hyperv/driver.rb +10 -9
- data/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 +3 -3
- data/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 +6 -6
- data/plugins/providers/virtualbox/action.rb +2 -0
- data/plugins/providers/virtualbox/action/clean_machine_folder.rb +10 -1
- data/plugins/providers/virtualbox/action/export.rb +4 -2
- data/plugins/providers/virtualbox/action/import.rb +8 -4
- data/plugins/providers/virtualbox/action/prepare_clone_snapshot.rb +4 -2
- data/plugins/providers/virtualbox/action/snapshot_delete.rb +4 -2
- data/plugins/providers/virtualbox/action/snapshot_restore.rb +4 -2
- data/plugins/providers/virtualbox/cap/cleanup_disks.rb +54 -0
- data/plugins/providers/virtualbox/cap/configure_disks.rb +287 -0
- data/plugins/providers/virtualbox/cap/validate_disk_ext.rb +27 -0
- data/plugins/providers/virtualbox/driver/base.rb +15 -0
- data/plugins/providers/virtualbox/driver/meta.rb +14 -2
- data/plugins/providers/virtualbox/driver/version_5_0.rb +142 -2
- data/plugins/providers/virtualbox/driver/version_6_1.rb +39 -0
- data/plugins/providers/virtualbox/plugin.rb +21 -0
- data/plugins/provisioners/ansible/cap/guest/alpine/ansible_install.rb +44 -0
- data/plugins/provisioners/ansible/cap/guest/arch/ansible_install.rb +20 -3
- data/plugins/provisioners/ansible/cap/guest/debian/ansible_install.rb +4 -5
- data/plugins/provisioners/ansible/cap/guest/fedora/ansible_install.rb +2 -2
- data/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb +2 -2
- data/plugins/provisioners/ansible/cap/guest/pip/pip.rb +8 -4
- data/plugins/provisioners/ansible/cap/guest/redhat/ansible_install.rb +2 -2
- data/plugins/provisioners/ansible/cap/guest/suse/ansible_install.rb +2 -1
- data/plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install.rb +3 -3
- data/plugins/provisioners/ansible/plugin.rb +5 -0
- data/plugins/provisioners/ansible/provisioner/base.rb +1 -1
- data/plugins/provisioners/container/client.rb +203 -0
- data/plugins/provisioners/container/config.rb +83 -0
- data/plugins/provisioners/container/installer.rb +13 -0
- data/plugins/provisioners/container/plugin.rb +23 -0
- data/plugins/provisioners/container/provisioner.rb +28 -0
- data/plugins/provisioners/docker/cap/{redhat → centos}/docker_install.rb +10 -7
- data/plugins/provisioners/docker/cap/centos/docker_start_service.rb +24 -0
- data/plugins/provisioners/docker/client.rb +4 -175
- data/plugins/provisioners/docker/config.rb +2 -72
- data/plugins/provisioners/docker/installer.rb +3 -5
- data/plugins/provisioners/docker/plugin.rb +6 -6
- data/plugins/provisioners/docker/provisioner.rb +4 -10
- data/plugins/provisioners/podman/cap/centos/podman_install.rb +35 -0
- data/plugins/provisioners/podman/cap/linux/podman_installed.rb +13 -0
- data/plugins/provisioners/podman/cap/redhat/podman_install.rb +26 -0
- data/plugins/provisioners/podman/client.rb +12 -0
- data/plugins/provisioners/podman/config.rb +28 -0
- data/plugins/provisioners/podman/installer.rb +33 -0
- data/plugins/provisioners/podman/plugin.rb +38 -0
- data/plugins/provisioners/podman/provisioner.rb +52 -0
- data/plugins/provisioners/salt/provisioner.rb +4 -0
- data/plugins/provisioners/shell/config.rb +1 -6
- data/plugins/provisioners/shell/provisioner.rb +54 -25
- data/plugins/synced_folders/smb/synced_folder.rb +1 -1
- data/templates/commands/init/Vagrantfile.erb +1 -1
- data/templates/locales/en.yml +123 -4
- data/templates/locales/providers_docker.yml +2 -0
- data/templates/nfs/exports_darwin.erb +7 -0
- data/vagrant.gemspec +8 -9
- data/version.txt +1 -1
- metadata +3731 -3663
- data/lib/vagrant/action/builtin/after_trigger.rb +0 -31
- data/lib/vagrant/action/builtin/before_trigger.rb +0 -28
- data/plugins/provisioners/docker/cap/redhat/docker_start_service.rb +0 -16
@@ -6,6 +6,11 @@ module VagrantPlugins
|
|
6
6
|
name "Darwin guest"
|
7
7
|
description "Darwin guest support."
|
8
8
|
|
9
|
+
action_hook(:apfs_firmlinks, :synced_folders) do |hook|
|
10
|
+
require_relative "cap/mount_vmware_shared_folder"
|
11
|
+
hook.prepend(Vagrant::Action::Builtin::Delayed, Cap::MountVmwareSharedFolder.method(:write_apfs_firmlinks))
|
12
|
+
end
|
13
|
+
|
9
14
|
guest(:darwin, :bsd) do
|
10
15
|
require_relative "guest"
|
11
16
|
Guest
|
@@ -10,7 +10,6 @@ module VagrantPlugins
|
|
10
10
|
extend Vagrant::Util::GuestInspection::Linux
|
11
11
|
|
12
12
|
NETPLAN_DEFAULT_VERSION = 2
|
13
|
-
NETPLAN_DEFAULT_RENDERER = "networkd".freeze
|
14
13
|
NETPLAN_DIRECTORY = "/etc/netplan".freeze
|
15
14
|
NETWORKD_DIRECTORY = "/etc/systemd/network".freeze
|
16
15
|
|
@@ -61,12 +60,21 @@ module VagrantPlugins
|
|
61
60
|
# By default, netplan expects the renderer to be systemd-networkd,
|
62
61
|
# but if any device is managed by NetworkManager, then we use that renderer
|
63
62
|
# ref: https://netplan.io/reference
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
if systemd_networkd?(comm)
|
64
|
+
renderer = "networkd"
|
65
|
+
ethernets.keys.each do |k|
|
66
|
+
if nm_controlled?(comm, k)
|
67
|
+
render = "NetworkManager"
|
68
|
+
if !nmcli?(comm)
|
69
|
+
raise Vagrant::Errors::NetworkManagerNotInstalled, device: k
|
70
|
+
end
|
71
|
+
break
|
72
|
+
end
|
69
73
|
end
|
74
|
+
elsif nmcli?(comm)
|
75
|
+
renderer = "NetworkManager"
|
76
|
+
else
|
77
|
+
raise Vagrant::Errors::NetplanNoAvailableRenderers
|
70
78
|
end
|
71
79
|
|
72
80
|
np_config = {"network" => {"version" => NETPLAN_DEFAULT_VERSION,
|
@@ -1,10 +1,18 @@
|
|
1
|
+
require 'vagrant/util/guest_inspection'
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module GuestLinux
|
3
5
|
module Cap
|
4
6
|
class Halt
|
7
|
+
extend Vagrant::Util::GuestInspection::Linux
|
8
|
+
|
5
9
|
def self.halt(machine)
|
6
10
|
begin
|
7
|
-
machine.communicate
|
11
|
+
if systemd?(machine.communicate)
|
12
|
+
machine.communicate.sudo("systemctl poweroff")
|
13
|
+
else
|
14
|
+
machine.communicate.sudo("shutdown -h now")
|
15
|
+
end
|
8
16
|
rescue IOError, Vagrant::Errors::SSHDisconnected
|
9
17
|
# Do nothing, because it probably means the machine shut down
|
10
18
|
# and SSH connection was lost.
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "fileutils"
|
1
2
|
require "shellwords"
|
2
3
|
require_relative "../../../synced_folders/unix_mount_helpers"
|
3
4
|
|
@@ -34,10 +35,17 @@ module VagrantPlugins
|
|
34
35
|
mnt_opts << "credentials=/etc/smb_creds_#{name}"
|
35
36
|
mnt_opts << "uid=#{mount_uid}"
|
36
37
|
mnt_opts << "gid=#{mount_gid}"
|
38
|
+
if !ENV['VAGRANT_DISABLE_SMBMFSYMLINKS']
|
39
|
+
mnt_opts << "mfsymlinks"
|
40
|
+
end
|
37
41
|
|
38
42
|
mnt_opts = merge_mount_options(mnt_opts, options[:mount_options] || [])
|
39
43
|
|
40
44
|
mount_options = "-o #{mnt_opts.join(",")}"
|
45
|
+
if mount_options.include?("mfsymlinks")
|
46
|
+
display_mfsymlinks_warning(machine.env)
|
47
|
+
end
|
48
|
+
|
41
49
|
mount_command = "mount -t cifs #{mount_options} #{mount_device} #{expanded_guest_path}"
|
42
50
|
|
43
51
|
# Create the guest path if it doesn't exist
|
@@ -94,6 +102,14 @@ SCRIPT
|
|
94
102
|
[key, value].compact.join("=")
|
95
103
|
end
|
96
104
|
end
|
105
|
+
|
106
|
+
def self.display_mfsymlinks_warning(env)
|
107
|
+
d_file = env.data_dir.join("mfsymlinks_warning")
|
108
|
+
if !d_file.exist?
|
109
|
+
FileUtils.touch(d_file.to_path)
|
110
|
+
env.ui.warn(I18n.t("vagrant.actions.vm.smb.mfsymlink_warning"))
|
111
|
+
end
|
112
|
+
end
|
97
113
|
end
|
98
114
|
end
|
99
115
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'vagrant/util/guest_inspection'
|
2
|
+
require "log4r"
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module GuestLinux
|
6
|
+
module Cap
|
7
|
+
class Reboot
|
8
|
+
extend Vagrant::Util::GuestInspection::Linux
|
9
|
+
MAX_REBOOT_RETRY_DURATION = 120
|
10
|
+
|
11
|
+
def self.reboot(machine)
|
12
|
+
@logger = Log4r::Logger.new("vagrant::linux::reboot")
|
13
|
+
if systemd?(machine.communicate)
|
14
|
+
reboot_script = "systemctl reboot"
|
15
|
+
else
|
16
|
+
reboot_script = "reboot"
|
17
|
+
end
|
18
|
+
|
19
|
+
comm = machine.communicate
|
20
|
+
|
21
|
+
@logger.debug("Issuing reboot command for guest")
|
22
|
+
comm.sudo(reboot_script)
|
23
|
+
|
24
|
+
machine.ui.info(I18n.t("vagrant.guests.capabilities.rebooting"))
|
25
|
+
|
26
|
+
@logger.debug("Waiting for machine to finish rebooting")
|
27
|
+
|
28
|
+
wait_remaining = MAX_REBOOT_RETRY_DURATION
|
29
|
+
begin
|
30
|
+
wait_for_reboot(machine)
|
31
|
+
rescue Vagrant::Errors::MachineGuestNotReady => e
|
32
|
+
raise if wait_remaining < 0
|
33
|
+
@logger.warn("Machine not ready, cannot start reboot yet. Trying again")
|
34
|
+
sleep(5)
|
35
|
+
wait_remaining -= 5
|
36
|
+
retry
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.wait_for_reboot(machine)
|
41
|
+
while !machine.guest.ready?
|
42
|
+
sleep 10
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -82,6 +82,16 @@ module VagrantPlugins
|
|
82
82
|
Cap::ReadIPAddress
|
83
83
|
end
|
84
84
|
|
85
|
+
guest_capability(:linux, :wait_for_reboot) do
|
86
|
+
require_relative "cap/reboot"
|
87
|
+
Cap::Reboot
|
88
|
+
end
|
89
|
+
|
90
|
+
guest_capability(:linux, :reboot) do
|
91
|
+
require_relative "cap/reboot"
|
92
|
+
Cap::Reboot
|
93
|
+
end
|
94
|
+
|
85
95
|
guest_capability(:linux, :remove_public_key) do
|
86
96
|
require_relative "cap/public_key"
|
87
97
|
Cap::PublicKey
|
@@ -10,8 +10,10 @@ module VagrantPlugins
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# Detect various flavors we care about
|
13
|
-
if output =~ /(
|
13
|
+
if output =~ /(Red Hat Enterprise|Scientific|Cloud|Virtuozzo)\s*Linux( .+)? release 7/i
|
14
14
|
return :rhel_7
|
15
|
+
elsif output =~ /(Red Hat Enterprise|Scientific|Cloud|Virtuozzo)\s*Linux( .+)? release 8/i
|
16
|
+
return :rhel_8
|
15
17
|
else
|
16
18
|
return :rhel
|
17
19
|
end
|
@@ -5,7 +5,7 @@ module VagrantPlugins
|
|
5
5
|
def self.nfs_client_install(machine)
|
6
6
|
machine.communicate.sudo <<-EOH.gsub(/^ {12}/, '')
|
7
7
|
if command -v dnf; then
|
8
|
-
if `dnf info -q libnfs-utils > /dev/null 2>&1` ; then
|
8
|
+
if `dnf info -q libnfs-utils > /dev/null 2>&1` ; then
|
9
9
|
dnf -y install nfs-utils libnfs-utils portmap
|
10
10
|
else
|
11
11
|
dnf -y install nfs-utils nfs-utils-lib portmap
|
@@ -15,7 +15,7 @@ module VagrantPlugins
|
|
15
15
|
fi
|
16
16
|
|
17
17
|
if test $(ps -o comm= 1) == 'systemd'; then
|
18
|
-
/bin/systemctl restart rpcbind nfs
|
18
|
+
/bin/systemctl restart rpcbind nfs-server
|
19
19
|
else
|
20
20
|
/etc/init.d/rpcbind restart
|
21
21
|
/etc/init.d/nfs restart
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestRedHat
|
3
|
+
module Cap
|
4
|
+
class SMB
|
5
|
+
def self.smb_install(machine)
|
6
|
+
comm = machine.communicate
|
7
|
+
if !comm.test("test -f /sbin/mount.cifs")
|
8
|
+
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
9
|
+
if command -v dnf; then
|
10
|
+
dnf -y install cifs-utils
|
11
|
+
else
|
12
|
+
yum -y install cifs-utils
|
13
|
+
fi
|
14
|
+
EOH
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -5,8 +5,8 @@ module VagrantPlugins
|
|
5
5
|
def self.change_host_name(machine, name)
|
6
6
|
comm = machine.communicate
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
basename = name.split(".", 2)[0]
|
9
|
+
if !comm.test('test "$(hostnamectl --static status)" = "#{basename}"', sudo: false)
|
10
10
|
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
11
11
|
hostnamectl set-hostname '#{basename}'
|
12
12
|
|
@@ -37,7 +37,7 @@ module VagrantPlugins
|
|
37
37
|
|
38
38
|
# Ensure the user's ssh directory exists
|
39
39
|
remote_ssh_dir = "#{home_dir}\\.ssh"
|
40
|
-
comm.execute("
|
40
|
+
comm.execute("New-Item -Path '#{remote_ssh_dir}' -ItemType directory -Force", shell: "powershell")
|
41
41
|
remote_upload_path = "#{temp_dir}\\vagrant-insert-pubkey-#{Time.now.to_i}"
|
42
42
|
remote_authkeys_path = "#{remote_ssh_dir}\\authorized_keys"
|
43
43
|
|
@@ -55,7 +55,7 @@ module VagrantPlugins
|
|
55
55
|
File.write(keys_file.path, keys.join("\r\n") + "\r\n")
|
56
56
|
comm.upload(keys_file.path, remote_upload_path)
|
57
57
|
keys_file.delete
|
58
|
-
comm.execute
|
58
|
+
comm.execute(<<-EOC.gsub(/^\s*/, ""), shell: "powershell")
|
59
59
|
Set-Acl "#{remote_upload_path}" (Get-Acl "#{remote_authkeys_path}")
|
60
60
|
Move-Item -Force "#{remote_upload_path}" "#{remote_authkeys_path}"
|
61
61
|
EOC
|
@@ -67,7 +67,7 @@ module VagrantPlugins
|
|
67
67
|
# @return [Hash] {:temp, :home}
|
68
68
|
def self.fetch_guest_paths(communicator)
|
69
69
|
output = ""
|
70
|
-
communicator.execute("
|
70
|
+
communicator.execute("Write-Output $env:TEMP\nWrite-Output $env:USERPROFILE", shell: "powershell") do |type, data|
|
71
71
|
if type == :stdout
|
72
72
|
output << data
|
73
73
|
end
|
@@ -28,8 +28,9 @@ module VagrantPlugins
|
|
28
28
|
wait_remaining = MAX_REBOOT_RETRY_DURATION
|
29
29
|
begin
|
30
30
|
wait_for_reboot(machine)
|
31
|
-
rescue
|
31
|
+
rescue => err
|
32
32
|
raise if wait_remaining < 0
|
33
|
+
@logger.debug("Exception caught while waiting for reboot: #{err}")
|
33
34
|
@logger.warn("Machine not ready, cannot start reboot yet. Trying again")
|
34
35
|
sleep(5)
|
35
36
|
wait_remaining -= 5
|
@@ -67,6 +67,7 @@ module VagrantPlugins
|
|
67
67
|
|
68
68
|
nfs_opts_setup(folders)
|
69
69
|
folders = folder_dupe_check(folders)
|
70
|
+
ips = ips.uniq
|
70
71
|
output = Vagrant::Util::TemplateRenderer.render('nfs/exports_linux',
|
71
72
|
uuid: id,
|
72
73
|
ips: ips,
|
@@ -77,7 +78,7 @@ module VagrantPlugins
|
|
77
78
|
sleep 0.5
|
78
79
|
|
79
80
|
nfs_cleanup("#{Process.uid} #{id}")
|
80
|
-
output =
|
81
|
+
output = nfs_exports_content + output
|
81
82
|
nfs_write_exports(output)
|
82
83
|
|
83
84
|
if nfs_running?(nfs_check_command)
|
@@ -93,7 +94,7 @@ module VagrantPlugins
|
|
93
94
|
"systemctl --no-pager --no-legend --plain list-unit-files --all --type=service " \
|
94
95
|
"| grep #{nfs_service_name_systemd}").exit_code == 0
|
95
96
|
else
|
96
|
-
Vagrant::Util::Subprocess.execute(
|
97
|
+
Vagrant::Util::Subprocess.execute(modinfo_path, "nfsd").exit_code == 0 ||
|
97
98
|
Vagrant::Util::Subprocess.execute("grep", "nfsd", "/proc/filesystems").exit_code == 0
|
98
99
|
end
|
99
100
|
end
|
@@ -261,6 +262,24 @@ module VagrantPlugins
|
|
261
262
|
Vagrant::Util::Subprocess.execute(*Shellwords.split(check_command)).exit_code == 0
|
262
263
|
end
|
263
264
|
|
265
|
+
def self.modinfo_path
|
266
|
+
if !defined?(@_modinfo_path)
|
267
|
+
@_modinfo_path = Vagrant::Util::Which.which("modinfo")
|
268
|
+
|
269
|
+
if @_modinfo_path.to_s.empty?
|
270
|
+
path = "/sbin/modinfo"
|
271
|
+
if File.file?(path)
|
272
|
+
@_modinfo_path = path
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
if @_modinfo_path.to_s.empty?
|
277
|
+
@_modinfo_path = "modinfo"
|
278
|
+
end
|
279
|
+
end
|
280
|
+
@_modinfo_path
|
281
|
+
end
|
282
|
+
|
264
283
|
# @private
|
265
284
|
# Reset the cached values for capability. This is not considered a public
|
266
285
|
# API and should only be used for testing.
|
@@ -0,0 +1,199 @@
|
|
1
|
+
require "log4r"
|
2
|
+
require "securerandom"
|
3
|
+
|
4
|
+
require "vagrant/util/numeric"
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module Kernel_V2
|
8
|
+
class VagrantConfigDisk < Vagrant.plugin("2", :config)
|
9
|
+
#-------------------------------------------------------------------
|
10
|
+
# Config class for a given Disk
|
11
|
+
#-------------------------------------------------------------------
|
12
|
+
|
13
|
+
DEFAULT_DISK_TYPES = [:disk, :dvd, :floppy].freeze
|
14
|
+
|
15
|
+
# Note: This value is for internal use only
|
16
|
+
#
|
17
|
+
# @return [String]
|
18
|
+
attr_reader :id
|
19
|
+
|
20
|
+
# File name for the given disk. Defaults to a generated name that is:
|
21
|
+
#
|
22
|
+
# vagrant_<disk_type>_<short_uuid>
|
23
|
+
#
|
24
|
+
# @return [String]
|
25
|
+
attr_accessor :name
|
26
|
+
|
27
|
+
# Type of disk to create. Defaults to `:disk`
|
28
|
+
#
|
29
|
+
# @return [Symbol]
|
30
|
+
attr_accessor :type
|
31
|
+
|
32
|
+
# Type of disk extension to create. Defaults to `vdi`
|
33
|
+
#
|
34
|
+
# @return [String]
|
35
|
+
attr_accessor :disk_ext
|
36
|
+
|
37
|
+
# Size of disk to create
|
38
|
+
#
|
39
|
+
# @return [Integer,String]
|
40
|
+
attr_accessor :size
|
41
|
+
|
42
|
+
# Path to the location of the disk file (Optional)
|
43
|
+
#
|
44
|
+
# @return [String]
|
45
|
+
attr_accessor :file
|
46
|
+
|
47
|
+
# Determines if this disk is the _main_ disk, or an attachment.
|
48
|
+
# Defaults to true.
|
49
|
+
#
|
50
|
+
# @return [Boolean]
|
51
|
+
attr_accessor :primary
|
52
|
+
|
53
|
+
# Provider specific options
|
54
|
+
#
|
55
|
+
# @return [Hash]
|
56
|
+
attr_accessor :provider_config
|
57
|
+
|
58
|
+
def initialize(type)
|
59
|
+
@logger = Log4r::Logger.new("vagrant::config::vm::disk")
|
60
|
+
|
61
|
+
@type = type
|
62
|
+
@provider_config = {}
|
63
|
+
|
64
|
+
@name = UNSET_VALUE
|
65
|
+
@provider_type = UNSET_VALUE
|
66
|
+
@size = UNSET_VALUE
|
67
|
+
@primary = UNSET_VALUE
|
68
|
+
@file = UNSET_VALUE
|
69
|
+
@disk_ext = UNSET_VALUE
|
70
|
+
|
71
|
+
# Internal options
|
72
|
+
@id = SecureRandom.uuid
|
73
|
+
end
|
74
|
+
|
75
|
+
# Helper method for storing provider specific config options
|
76
|
+
#
|
77
|
+
# Expected format is:
|
78
|
+
#
|
79
|
+
# - `provider__diskoption: value`
|
80
|
+
# - `{provider: {diskoption: value, otherdiskoption: value, ...}`
|
81
|
+
#
|
82
|
+
# Duplicates will be overriden
|
83
|
+
#
|
84
|
+
# @param [Hash] options
|
85
|
+
def add_provider_config(**options, &block)
|
86
|
+
current = {}
|
87
|
+
options.each do |k,v|
|
88
|
+
opts = k.to_s.split("__")
|
89
|
+
|
90
|
+
if opts.size == 2
|
91
|
+
current[opts[0].to_sym] = {opts[1].to_sym => v}
|
92
|
+
elsif v.is_a?(Hash)
|
93
|
+
current[k] = v
|
94
|
+
else
|
95
|
+
@logger.warn("Disk option '#{k}' found that does not match expected provider disk config schema.")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
current = @provider_config.merge(current) if !@provider_config.empty?
|
100
|
+
@provider_config = current
|
101
|
+
end
|
102
|
+
|
103
|
+
def finalize!
|
104
|
+
# Ensure all config options are set to nil or default value if untouched
|
105
|
+
# by user
|
106
|
+
@type = :disk if @type == UNSET_VALUE
|
107
|
+
@size = nil if @size == UNSET_VALUE
|
108
|
+
@file = nil if @file == UNSET_VALUE
|
109
|
+
|
110
|
+
@disk_ext = "vdi" if @disk_ext == UNSET_VALUE
|
111
|
+
|
112
|
+
if @primary == UNSET_VALUE
|
113
|
+
@primary = false
|
114
|
+
end
|
115
|
+
|
116
|
+
if @name == UNSET_VALUE
|
117
|
+
if @primary
|
118
|
+
@name = "vagrant_primary"
|
119
|
+
else
|
120
|
+
@name = nil
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
@provider_config = nil if @provider_config == {}
|
125
|
+
end
|
126
|
+
|
127
|
+
# @return [Array] array of strings of error messages from config option validation
|
128
|
+
def validate(machine)
|
129
|
+
errors = _detected_errors
|
130
|
+
|
131
|
+
# validate type with list of known disk types
|
132
|
+
|
133
|
+
if !DEFAULT_DISK_TYPES.include?(@type)
|
134
|
+
errors << I18n.t("vagrant.config.disk.invalid_type", type: @type,
|
135
|
+
types: DEFAULT_DISK_TYPES.join(', '))
|
136
|
+
end
|
137
|
+
|
138
|
+
if @disk_ext
|
139
|
+
@disk_ext = @disk_ext.downcase
|
140
|
+
|
141
|
+
if machine.provider.capability?(:validate_disk_ext)
|
142
|
+
if !machine.provider.capability(:validate_disk_ext, @disk_ext)
|
143
|
+
if machine.provider.capability?(:get_default_disk_ext)
|
144
|
+
disk_exts = machine.provider.capability(:get_default_disk_ext).join(', ')
|
145
|
+
else
|
146
|
+
disk_exts = "not found"
|
147
|
+
end
|
148
|
+
errors << I18n.t("vagrant.config.disk.invalid_ext", ext: @disk_ext,
|
149
|
+
name: @name,
|
150
|
+
exts: disk_exts)
|
151
|
+
end
|
152
|
+
else
|
153
|
+
@logger.warn("No provider capability defined to validate 'disk_ext' type")
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
if @size && !@size.is_a?(Integer)
|
158
|
+
if @size.is_a?(String)
|
159
|
+
@size = Vagrant::Util::Numeric.string_to_bytes(@size)
|
160
|
+
end
|
161
|
+
|
162
|
+
if !@size
|
163
|
+
errors << I18n.t("vagrant.config.disk.invalid_size", name: @name, machine: machine.name)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
if @file
|
168
|
+
if !@file.is_a?(String)
|
169
|
+
errors << I18n.t("vagrant.config.disk.invalid_file_type", file: @file, machine: machine.name)
|
170
|
+
elsif !File.file?(@file)
|
171
|
+
errors << I18n.t("vagrant.config.disk.missing_file", file_path: @file,
|
172
|
+
name: @name, machine: machine.name)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
if @provider_config
|
177
|
+
if !@provider_config.keys.include?(machine.provider_name)
|
178
|
+
machine.env.ui.warn(I18n.t("vagrant.config.disk.missing_provider",
|
179
|
+
machine: machine.name,
|
180
|
+
provider_name: machine.provider_name))
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
if !@name
|
185
|
+
errors << I18n.t("vagrant.config.disk.no_name_set", machine: machine.name)
|
186
|
+
end
|
187
|
+
|
188
|
+
errors
|
189
|
+
end
|
190
|
+
|
191
|
+
# The String representation of this Disk.
|
192
|
+
#
|
193
|
+
# @return [String]
|
194
|
+
def to_s
|
195
|
+
"disk config"
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|