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
@@ -56,7 +56,7 @@ module VagrantPlugins
|
|
56
56
|
errors << "winrm.port cannot be nil." if @port.nil?
|
57
57
|
errors << "winrm.guest_port cannot be nil." if @guest_port.nil?
|
58
58
|
errors << "winrm.max_tries cannot be nil." if @max_tries.nil?
|
59
|
-
errors << "winrm.retry_delay cannot be nil." if @
|
59
|
+
errors << "winrm.retry_delay cannot be nil." if @retry_delay.nil?
|
60
60
|
errors << "winrm.timeout cannot be nil." if @timeout.nil?
|
61
61
|
errors << "winrm.execution_time_limit cannot be nil." if @execution_time_limit.nil?
|
62
62
|
unless @ssl_peer_verification == true || @ssl_peer_verification == false
|
@@ -19,7 +19,7 @@ module VagrantPlugins
|
|
19
19
|
|
20
20
|
# Exit code generated when user is invalid. Can occur
|
21
21
|
# after a hostname update
|
22
|
-
INVALID_USERID_EXITCODE = -
|
22
|
+
INVALID_USERID_EXITCODE = -2147024809
|
23
23
|
|
24
24
|
# These are the exceptions that we retry because they represent
|
25
25
|
# errors that are generally fixed from a retry and don't
|
@@ -1,27 +1,39 @@
|
|
1
1
|
require File.expand_path("../../ssh/communicator", __FILE__)
|
2
2
|
|
3
|
+
require 'net/sftp'
|
4
|
+
|
3
5
|
module VagrantPlugins
|
4
6
|
module CommunicatorWinSSH
|
5
7
|
# This class provides communication with a Windows VM running
|
6
8
|
# the Windows native port of OpenSSH
|
7
9
|
class Communicator < VagrantPlugins::CommunicatorSSH::Communicator
|
10
|
+
# Command to run when checking if connection is ready and working
|
11
|
+
READY_COMMAND="dir"
|
8
12
|
|
9
13
|
def initialize(machine)
|
10
14
|
super
|
11
15
|
@logger = Log4r::Logger.new("vagrant::communication::winssh")
|
12
16
|
end
|
13
17
|
|
18
|
+
# Wrap the shell if required. By default we are using powershell
|
19
|
+
# which requires no modification. If cmd is defined as shell, add
|
20
|
+
# prefix to start within cmd.exe
|
21
|
+
def shell_cmd(opts)
|
22
|
+
case opts[:shell].to_s
|
23
|
+
when "cmd"
|
24
|
+
"cmd.exe /c '#{opts[:command]}'"
|
25
|
+
else
|
26
|
+
opts[:command]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
14
30
|
# Executes the command on an SSH connection within a login shell.
|
15
31
|
def shell_execute(connection, command, **opts)
|
16
|
-
opts
|
17
|
-
sudo: false,
|
18
|
-
shell: nil
|
19
|
-
}.merge(opts)
|
32
|
+
opts[:shell] ||= machine_config_ssh.shell
|
20
33
|
|
21
|
-
|
22
|
-
shell = (opts[:shell] || machine_config_ssh.shell).to_s
|
34
|
+
command = shell_cmd(opts.merge(command: command))
|
23
35
|
|
24
|
-
@logger.info("Execute: #{command}
|
36
|
+
@logger.info("Execute: #{command} - opts: #{opts}")
|
25
37
|
exit_status = nil
|
26
38
|
|
27
39
|
# Open the channel so we can execute or command
|
@@ -31,36 +43,10 @@ module VagrantPlugins
|
|
31
43
|
stderr_marker_found = false
|
32
44
|
stderr_data_buffer = ''
|
33
45
|
|
34
|
-
|
35
|
-
|
36
|
-
remote_name = "#{machine_config_ssh.upload_directory}\\#{File.basename(tfile.path)}.#{remote_ext}"
|
37
|
-
|
38
|
-
if shell == "powershell"
|
39
|
-
base_cmd = "powershell -File #{remote_name}"
|
40
|
-
tfile.puts <<-SCRIPT.force_encoding('ASCII-8BIT')
|
41
|
-
Remove-Item #{remote_name}
|
42
|
-
Write-Host #{CMD_GARBAGE_MARKER}
|
43
|
-
[Console]::Error.WriteLine("#{CMD_GARBAGE_MARKER}")
|
44
|
-
#{command}
|
45
|
-
SCRIPT
|
46
|
-
else
|
47
|
-
base_cmd = remote_name
|
48
|
-
tfile.puts <<-SCRIPT.force_encoding('ASCII-8BIT')
|
49
|
-
ECHO OFF
|
50
|
-
ECHO #{CMD_GARBAGE_MARKER}
|
51
|
-
ECHO #{CMD_GARBAGE_MARKER} 1>&2
|
52
|
-
#{command}
|
53
|
-
SCRIPT
|
54
|
-
end
|
55
|
-
|
56
|
-
tfile.close
|
57
|
-
upload(tfile.path, remote_name)
|
58
|
-
tfile.delete
|
59
|
-
|
60
|
-
base_cmd = shell_cmd(opts.merge(shell: base_cmd))
|
61
|
-
@logger.debug("Base SSH exec command: #{base_cmd}")
|
46
|
+
@logger.debug("Base SSH exec command: #{command}")
|
47
|
+
command = "$ProgressPreference = 'SilentlyContinue';Write-Output #{CMD_GARBAGE_MARKER};[Console]::Error.WriteLine('#{CMD_GARBAGE_MARKER}');#{command}"
|
62
48
|
|
63
|
-
ch.exec(
|
49
|
+
ch.exec(command) do |ch2, _|
|
64
50
|
# Setup the channel callbacks so we can get data and exit status
|
65
51
|
ch2.on_data do |ch3, data|
|
66
52
|
# Filter out the clear screen command
|
@@ -90,14 +76,14 @@ SCRIPT
|
|
90
76
|
stderr_data_buffer << data
|
91
77
|
marker_index = stderr_data_buffer.index(CMD_GARBAGE_MARKER)
|
92
78
|
if marker_index
|
93
|
-
|
79
|
+
stderr_marker_found = true
|
94
80
|
stderr_data_buffer.slice!(0, marker_index + CMD_GARBAGE_MARKER.size)
|
95
81
|
data.replace(stderr_data_buffer.lstrip)
|
96
82
|
data_buffer = nil
|
97
83
|
end
|
98
84
|
end
|
99
85
|
|
100
|
-
if block_given? &&
|
86
|
+
if block_given? && stderr_marker_found && !data.empty?
|
101
87
|
yield :stderr, data
|
102
88
|
end
|
103
89
|
end
|
@@ -156,6 +142,108 @@ SCRIPT
|
|
156
142
|
@machine.config.winssh
|
157
143
|
end
|
158
144
|
|
145
|
+
def download(from, to=nil)
|
146
|
+
@logger.debug("Downloading: #{from} to #{to}")
|
147
|
+
|
148
|
+
sftp_connect do |sftp|
|
149
|
+
sftp.download!(from, to)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Note: I could not get Net::SFTP to throw a permissions denied error,
|
154
|
+
# even when uploading to a directory where I did not have write
|
155
|
+
# privileges. I believe this is because Windows SSH sessions are started
|
156
|
+
# in an elevated process.
|
157
|
+
def upload(from, to)
|
158
|
+
to = Vagrant::Util::Platform.unix_windows_path(to)
|
159
|
+
@logger.debug("Uploading: #{from} to #{to}")
|
160
|
+
|
161
|
+
if File.directory?(from)
|
162
|
+
if from.end_with?(".")
|
163
|
+
@logger.debug("Uploading directory contents of: #{from}")
|
164
|
+
from = from.sub(/\.$/, "")
|
165
|
+
else
|
166
|
+
@logger.debug("Uploading full directory container of: #{from}")
|
167
|
+
to = File.join(to, File.basename(File.expand_path(from)))
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
sftp_connect do |sftp|
|
172
|
+
uploader = lambda do |path, remote_dest=nil|
|
173
|
+
if File.directory?(path)
|
174
|
+
Dir.new(path).each do |entry|
|
175
|
+
next if entry == "." || entry == ".."
|
176
|
+
full_path = File.join(path, entry)
|
177
|
+
dest = File.join(to, path.sub(/^#{Regexp.escape(from)}/, ""))
|
178
|
+
sftp.mkdir(dest)
|
179
|
+
uploader.call(full_path, dest)
|
180
|
+
end
|
181
|
+
else
|
182
|
+
if remote_dest
|
183
|
+
dest = File.join(remote_dest, File.basename(path))
|
184
|
+
else
|
185
|
+
dest = to
|
186
|
+
if to.end_with?(File::SEPARATOR)
|
187
|
+
dest = File.join(to, File.basename(path))
|
188
|
+
end
|
189
|
+
end
|
190
|
+
@logger.debug("Ensuring remote directory exists for destination upload")
|
191
|
+
sftp.mkdir(File.dirname(dest))
|
192
|
+
@logger.debug("Uploading file #{path} to remote #{dest}")
|
193
|
+
upload_file = File.open(path, "rb")
|
194
|
+
begin
|
195
|
+
sftp.upload!(upload_file, dest)
|
196
|
+
ensure
|
197
|
+
upload_file.close
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
uploader.call(from)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
# Opens an SFTP connection and yields it so that you can download and
|
206
|
+
# upload files. SFTP works more reliably than SCP on Windows due to
|
207
|
+
# issues with shell quoting and escaping.
|
208
|
+
def sftp_connect
|
209
|
+
# Connect to SFTP and yield the SFTP object
|
210
|
+
connect do |connection|
|
211
|
+
return yield connection.sftp
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
protected
|
216
|
+
|
217
|
+
# The WinSSH communicator connection provides isolated modification
|
218
|
+
# to the generated connection instances. This modification forces
|
219
|
+
# all provided commands to run within powershell
|
220
|
+
def connect(*args)
|
221
|
+
connection = nil
|
222
|
+
super { |c| connection = c }
|
223
|
+
|
224
|
+
if !connection.instance_variable_get(:@winssh_patched)
|
225
|
+
open_chan = connection.method(:open_channel)
|
226
|
+
connection.define_singleton_method(:open_channel) do |*args, &chan_block|
|
227
|
+
open_chan.call(*args) do |ch|
|
228
|
+
exec = ch.method(:exec)
|
229
|
+
ch.define_singleton_method(:exec) do |command, &block|
|
230
|
+
command = Base64.strict_encode64(command.encode("UTF-16LE", "UTF-8"))
|
231
|
+
command = "powershell -NoLogo -NonInteractive -ExecutionPolicy Bypass " \
|
232
|
+
"-NoProfile -EncodedCommand #{command}"
|
233
|
+
exec.call(command, &block)
|
234
|
+
end
|
235
|
+
chan_block.call(ch)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
connection.instance_variable_set(:@winssh_patched, true)
|
239
|
+
end
|
240
|
+
|
241
|
+
if block_given?
|
242
|
+
yield connection
|
243
|
+
else
|
244
|
+
connection
|
245
|
+
end
|
246
|
+
end
|
159
247
|
end
|
160
248
|
end
|
161
249
|
end
|
@@ -12,15 +12,11 @@ module VagrantPlugins
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def finalize!
|
15
|
-
@shell = "
|
15
|
+
@shell = "powershell" if @shell == UNSET_VALUE
|
16
16
|
@sudo_command = "%c" if @sudo_command == UNSET_VALUE
|
17
|
-
@upload_directory = "C
|
17
|
+
@upload_directory = "C:/Windows/Temp" if @upload_directory == UNSET_VALUE
|
18
18
|
if @export_command_template == UNSET_VALUE
|
19
|
-
|
20
|
-
@export_command_template = 'set %ENV_KEY%="%ENV_VALUE%"'
|
21
|
-
else
|
22
|
-
@export_command_template = '$env:%ENV_KEY%="%ENV_VALUE%"'
|
23
|
-
end
|
19
|
+
@export_command_template = '$env:%ENV_KEY%="%ENV_VALUE%"'
|
24
20
|
end
|
25
21
|
super
|
26
22
|
end
|
@@ -45,6 +45,22 @@ module VagrantPlugins
|
|
45
45
|
require_relative 'cap/smb'
|
46
46
|
Cap::SMB
|
47
47
|
end
|
48
|
+
|
49
|
+
def self.check_community_plugin
|
50
|
+
plugins = Vagrant::Plugin::Manager.instance.installed_plugins
|
51
|
+
if plugins.keys.include?("vagrant-alpine")
|
52
|
+
$stderr.puts <<-EOF
|
53
|
+
WARNING: Vagrant has detected the `vagrant-alpine` plugin. This plugin's
|
54
|
+
functionality has been merged into the main Vagrant project and should be
|
55
|
+
considered deprecated. To uninstall the plugin, run the command shown below:
|
56
|
+
|
57
|
+
vagrant plugin uninstall vagrant-alpine
|
58
|
+
|
59
|
+
EOF
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
self.check_community_plugin
|
48
64
|
end
|
49
65
|
end
|
50
66
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestCentos
|
3
|
+
module Cap
|
4
|
+
class Flavor
|
5
|
+
def self.flavor(machine)
|
6
|
+
# Read the version file
|
7
|
+
output = ""
|
8
|
+
machine.communicate.sudo("cat /etc/centos-release") do |_, data|
|
9
|
+
output = data
|
10
|
+
end
|
11
|
+
|
12
|
+
# Detect various flavors we care about
|
13
|
+
if output =~ /(CentOS)( .+)? 7/i
|
14
|
+
return :centos_7
|
15
|
+
elsif output =~ /(CentOS)( .+)? 8/i
|
16
|
+
return :centos_8
|
17
|
+
else
|
18
|
+
return :centos
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GuestCentos
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
6
|
+
name "CentOS guest"
|
7
|
+
description "CentOS guest support."
|
8
|
+
|
9
|
+
guest(:centos, :redhat) do
|
10
|
+
require_relative "guest"
|
11
|
+
Guest
|
12
|
+
end
|
13
|
+
|
14
|
+
guest_capability(:centos, :flavor) do
|
15
|
+
require_relative "cap/flavor"
|
16
|
+
Cap::Flavor
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,34 +1,120 @@
|
|
1
|
+
require "securerandom"
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module GuestDarwin
|
3
5
|
module Cap
|
4
6
|
class MountVmwareSharedFolder
|
7
|
+
# Entry point for hook to called delayed actions
|
8
|
+
# which finalizing the synced folders setup on
|
9
|
+
# the guest
|
10
|
+
def self.write_apfs_firmlinks(env)
|
11
|
+
if env && env[:machine] && delayed = apfs_firmlinks_delayed.delete(env[:machine].id)
|
12
|
+
delayed.call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Hash] storage location for delayed actions
|
17
|
+
def self.apfs_firmlinks_delayed
|
18
|
+
if !@_apfs_firmlinks
|
19
|
+
@_apfs_firmlinks = {}
|
20
|
+
end
|
21
|
+
@_apfs_firmlinks
|
22
|
+
end
|
5
23
|
|
6
24
|
# we seem to be unable to ask 'mount -t vmhgfs' to mount the roots
|
7
25
|
# of specific shares, so instead we symlink from what is already
|
8
|
-
# mounted by the guest tools
|
26
|
+
# mounted by the guest tools
|
9
27
|
# (ie. the behaviour of the VMware_fusion provider prior to 0.8.x)
|
10
28
|
|
11
29
|
def self.mount_vmware_shared_folder(machine, name, guestpath, options)
|
30
|
+
# Use this variable to determine which machines
|
31
|
+
# have been registered with after hook
|
32
|
+
@apply_firmlinks ||= Hash.new{ |h, k| h[k] = {bootstrap: false, content: []} }
|
33
|
+
|
12
34
|
machine.communicate.tap do |comm|
|
13
|
-
#
|
14
|
-
if comm.test("test -
|
15
|
-
|
35
|
+
# check if we are dealing with an APFS root container
|
36
|
+
if comm.test("test -d /System/Volumes/Data")
|
37
|
+
parts = Pathname.new(guestpath).descend.to_a
|
38
|
+
firmlink = parts[1].to_s
|
39
|
+
firmlink.slice!(0, 1) if firmlink.start_with?("/")
|
40
|
+
if parts.size > 2
|
41
|
+
guestpath = File.join("/System/Volumes/Data", guestpath)
|
42
|
+
else
|
43
|
+
guestpath = nil
|
44
|
+
end
|
16
45
|
end
|
17
46
|
|
18
|
-
#
|
19
|
-
if
|
20
|
-
comm.
|
47
|
+
# Remove existing symlink or directory if defined
|
48
|
+
if guestpath
|
49
|
+
if comm.test("test -L \"#{guestpath}\"")
|
50
|
+
comm.sudo("rm -f \"#{guestpath}\"")
|
51
|
+
elsif comm.test("test -d \"#{guestpath}\"")
|
52
|
+
comm.sudo("rm -Rf \"#{guestpath}\"")
|
53
|
+
end
|
54
|
+
|
55
|
+
# create intermediate directories if needed
|
56
|
+
intermediate_dir = File.dirname(guestpath)
|
57
|
+
if intermediate_dir != "/"
|
58
|
+
comm.sudo("mkdir -p \"#{intermediate_dir}\"")
|
59
|
+
end
|
60
|
+
|
61
|
+
comm.sudo("ln -s \"/Volumes/VMware Shared Folders/#{name}\" \"#{guestpath}\"")
|
21
62
|
end
|
22
63
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
64
|
+
if firmlink && !system_firmlink?(firmlink)
|
65
|
+
if guestpath.nil?
|
66
|
+
guestpath = "/Volumes/VMware Shared Folders/#{name}"
|
67
|
+
else
|
68
|
+
guestpath = File.join("/System/Volumes/Data", firmlink)
|
69
|
+
end
|
70
|
+
|
71
|
+
share_line = "#{firmlink}\t#{guestpath}"
|
72
|
+
|
73
|
+
# Check if the line is already defined. If so, bail since we are done
|
74
|
+
if !comm.test("[[ \"$(</etc/synthetic.conf)\" = *\"#{share_line}\"* ]]")
|
75
|
+
@apply_firmlinks[machine.id][:bootstrap] = true
|
76
|
+
end
|
77
|
+
|
78
|
+
# If we haven't already added our hook to apply firmlinks, do it now
|
79
|
+
if @apply_firmlinks[machine.id][:content].empty?
|
80
|
+
apfs_firmlinks_delayed[machine.id] = proc do
|
81
|
+
content = @apply_firmlinks[machine.id][:content].join("\n")
|
82
|
+
# Write out the synthetic file
|
83
|
+
comm.sudo("echo -e #{content.inspect} > /etc/synthetic.conf")
|
84
|
+
if @apply_firmlinks[:bootstrap]
|
85
|
+
# Re-bootstrap the root container to pick up firmlink updates
|
86
|
+
comm.sudo("/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -B")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
@apply_firmlinks[machine.id][:content] << share_line
|
27
91
|
end
|
92
|
+
end
|
93
|
+
end
|
28
94
|
|
29
|
-
|
30
|
-
|
95
|
+
# Check if firmlink is provided by the system
|
96
|
+
#
|
97
|
+
# @param [String] firmlink Firmlink path
|
98
|
+
# @return [Boolean]
|
99
|
+
def self.system_firmlink?(firmlink)
|
100
|
+
if !@_firmlinks
|
101
|
+
if File.exist?("/usr/share/firmlinks")
|
102
|
+
@_firmlinks = File.readlines("/usr/share/firmlinks").map do |line|
|
103
|
+
line.split.first
|
104
|
+
end
|
105
|
+
else
|
106
|
+
@_firmlinks = []
|
107
|
+
end
|
31
108
|
end
|
109
|
+
firmlink = "/#{firmlink}" if !firmlink.start_with?("/")
|
110
|
+
@_firmlinks.include?(firmlink)
|
111
|
+
end
|
112
|
+
|
113
|
+
# @private
|
114
|
+
# Reset the cached values for capability. This is not considered a public
|
115
|
+
# API and should only be used for testing.
|
116
|
+
def self.reset!
|
117
|
+
instance_variables.each(&method(:remove_instance_variable))
|
32
118
|
end
|
33
119
|
end
|
34
120
|
end
|