vagrant-unbundled 2.2.10.0 → 2.2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +60 -0
- data/Gemfile +1 -1
- data/README.md +4 -44
- data/RELEASE.md +1 -1
- data/contrib/zsh/_vagrant +3 -1
- data/contrib/zsh/generate_zsh_completion.rb +2 -3
- data/lib/vagrant.rb +0 -4
- data/lib/vagrant/action/builder.rb +6 -15
- data/lib/vagrant/action/builtin/box_add.rb +5 -1
- data/lib/vagrant/action/builtin/cloud_init_setup.rb +10 -15
- data/lib/vagrant/action/builtin/synced_folders.rb +8 -2
- data/lib/vagrant/action/runner.rb +1 -1
- data/lib/vagrant/box.rb +8 -2
- data/lib/vagrant/box_collection.rb +1 -1
- data/lib/vagrant/bundler.rb +43 -16
- data/lib/vagrant/machine.rb +8 -5
- data/lib/vagrant/machine_index.rb +1 -0
- data/lib/vagrant/plugin/v2/command.rb +2 -1
- data/lib/vagrant/shared_helpers.rb +8 -0
- data/lib/vagrant/util/downloader.rb +3 -2
- data/lib/vagrant/util/is_port_open.rb +1 -1
- data/lib/vagrant/util/mime.rb +92 -0
- data/lib/vagrant/util/platform.rb +2 -1
- data/lib/vagrant/util/template_renderer.rb +2 -2
- data/lib/vagrant/util/uploader.rb +7 -4
- 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 +9 -9
- 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/login/plugin.rb +0 -13
- data/plugins/guests/arch/cap/smb.rb +1 -1
- 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 +12 -2
- data/plugins/guests/darwin/plugin.rb +10 -0
- data/plugins/guests/debian/cap/change_host_name.rb +8 -7
- data/plugins/guests/linux/cap/mount_smb_shared_folder.rb +16 -41
- data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +6 -0
- data/plugins/guests/linux/cap/persist_mount_shared_folder.rb +18 -5
- data/plugins/guests/linux/cap/reboot.rb +10 -5
- data/plugins/guests/redhat/cap/change_host_name.rb +6 -2
- data/plugins/guests/suse/cap/change_host_name.rb +32 -11
- data/plugins/guests/windows/cap/reboot.rb +8 -4
- data/plugins/kernel_v2/config/cloud_init.rb +7 -0
- data/plugins/kernel_v2/config/disk.rb +1 -1
- data/plugins/kernel_v2/config/vm.rb +5 -4
- data/plugins/providers/hyperv/action.rb +1 -1
- data/plugins/providers/virtualbox/cap/mount_options.rb +1 -1
- data/plugins/providers/virtualbox/model/storage_controller_array.rb +4 -6
- data/plugins/providers/virtualbox/provider.rb +2 -1
- data/plugins/synced_folders/smb/cap/mount_options.rb +21 -1
- data/plugins/synced_folders/smb/plugin.rb +10 -0
- data/scripts/website_push_www.sh +1 -1
- data/vagrant.gemspec +5 -6
- data/version.txt +1 -1
- metadata +1202 -1595
- 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/scripts/website_push_docs.sh +0 -40
@@ -2,9 +2,6 @@ require "vagrant"
|
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
4
|
module LoginCommand
|
5
|
-
autoload :Client, File.expand_path("../client", __FILE__)
|
6
|
-
autoload :Errors, File.expand_path("../errors", __FILE__)
|
7
|
-
|
8
5
|
class Plugin < Vagrant.plugin("2")
|
9
6
|
name "vagrant-login"
|
10
7
|
description <<-DESC
|
@@ -13,18 +10,8 @@ module VagrantPlugins
|
|
13
10
|
|
14
11
|
command(:login) do
|
15
12
|
require File.expand_path("../../cloud/auth/login", __FILE__)
|
16
|
-
init!
|
17
13
|
VagrantPlugins::CloudCommand::AuthCommand::Command::Login
|
18
14
|
end
|
19
|
-
|
20
|
-
protected
|
21
|
-
|
22
|
-
def self.init!
|
23
|
-
return if defined?(@_init)
|
24
|
-
I18n.load_path << File.expand_path("../../cloud/locales/en.yml", __FILE__)
|
25
|
-
I18n.reload!
|
26
|
-
@_init = true
|
27
|
-
end
|
28
15
|
end
|
29
16
|
end
|
30
17
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestDarwin
|
3
|
+
module Cap
|
4
|
+
class DarwinVersion
|
5
|
+
|
6
|
+
VERSION_REGEX = /\d+.\d+.?\d*/.freeze
|
7
|
+
|
8
|
+
# Get the darwin version
|
9
|
+
#
|
10
|
+
# @param [Machine]
|
11
|
+
# @return [String] version of drawin
|
12
|
+
def self.darwin_version(machine)
|
13
|
+
output = ""
|
14
|
+
machine.communicate.sudo("sysctl kern.osrelease") do |_, data|
|
15
|
+
output = data
|
16
|
+
end
|
17
|
+
output.scan(VERSION_REGEX).first
|
18
|
+
end
|
19
|
+
|
20
|
+
# Get the darwin major version
|
21
|
+
#
|
22
|
+
# @param [Machine]
|
23
|
+
# @return [int] major version of drawin (nil if version is not detected)
|
24
|
+
def self.darwin_major_version(machine)
|
25
|
+
output = ""
|
26
|
+
machine.communicate.sudo("sysctl kern.osrelease") do |_, data|
|
27
|
+
output = data
|
28
|
+
end
|
29
|
+
version_string = output.scan(VERSION_REGEX).first
|
30
|
+
if version_string
|
31
|
+
major_version = version_string.split(".").first.to_i
|
32
|
+
else
|
33
|
+
major_version = nil
|
34
|
+
end
|
35
|
+
major_version
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -26,7 +26,7 @@ module VagrantPlugins
|
|
26
26
|
mount_options = options[:mount_options];
|
27
27
|
mount_command = "mount -t smbfs " +
|
28
28
|
(mount_options ? "-o '#{mount_options.join(",")}' " : "") +
|
29
|
-
"
|
29
|
+
"//#{options[:smb_username]}:#{smb_password}@#{options[:smb_host]}/#{name} " +
|
30
30
|
"#{expanded_guest_path}"
|
31
31
|
retryable(on: Vagrant::Errors::DarwinMountFailed, tries: 10, sleep: 2) do
|
32
32
|
machine.communicate.execute(
|
@@ -4,6 +4,9 @@ module VagrantPlugins
|
|
4
4
|
module GuestDarwin
|
5
5
|
module Cap
|
6
6
|
class MountVmwareSharedFolder
|
7
|
+
|
8
|
+
MACOS_BIGSUR_DARWIN_VERSION = 20.freeze
|
9
|
+
|
7
10
|
# Entry point for hook to called delayed actions
|
8
11
|
# which finalizing the synced folders setup on
|
9
12
|
# the guest
|
@@ -81,9 +84,16 @@ module VagrantPlugins
|
|
81
84
|
content = @apply_firmlinks[machine.id][:content].join("\n")
|
82
85
|
# Write out the synthetic file
|
83
86
|
comm.sudo("echo -e #{content.inspect} > /etc/synthetic.conf")
|
84
|
-
if @apply_firmlinks[:bootstrap]
|
87
|
+
if @apply_firmlinks[machine.id][:bootstrap]
|
88
|
+
if machine.guest.capability("darwin_major_version").to_i < MACOS_BIGSUR_DARWIN_VERSION
|
89
|
+
apfs_bootstrap_flag = "-B"
|
90
|
+
expected_rc = 0
|
91
|
+
else
|
92
|
+
apfs_bootstrap_flag = "-t"
|
93
|
+
expected_rc = 253
|
94
|
+
end
|
85
95
|
# Re-bootstrap the root container to pick up firmlink updates
|
86
|
-
comm.sudo("/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util
|
96
|
+
comm.sudo("/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util #{apfs_bootstrap_flag}", good_exit: [expected_rc])
|
87
97
|
end
|
88
98
|
end
|
89
99
|
end
|
@@ -31,6 +31,16 @@ module VagrantPlugins
|
|
31
31
|
Cap::ConfigureNetworks
|
32
32
|
end
|
33
33
|
|
34
|
+
guest_capability(:darwin, :darwin_version) do
|
35
|
+
require_relative "cap/darwin_version"
|
36
|
+
Cap::DarwinVersion
|
37
|
+
end
|
38
|
+
|
39
|
+
guest_capability(:darwin, :darwin_major_version) do
|
40
|
+
require_relative "cap/darwin_version"
|
41
|
+
Cap::DarwinVersion
|
42
|
+
end
|
43
|
+
|
34
44
|
guest_capability(:darwin, :halt) do
|
35
45
|
require_relative "cap/halt"
|
36
46
|
Cap::Halt
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "log4r"
|
2
2
|
require 'vagrant/util/guest_hosts'
|
3
|
+
require 'vagrant/util/guest_inspection'
|
3
4
|
require_relative "../../linux/cap/network_interfaces"
|
4
5
|
|
5
6
|
module VagrantPlugins
|
@@ -15,6 +16,13 @@ module VagrantPlugins
|
|
15
16
|
comm = machine.communicate
|
16
17
|
|
17
18
|
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
19
|
+
network_with_hostname = machine.config.vm.networks.map {|_, c| c if c[:hostname] }.compact[0]
|
20
|
+
if network_with_hostname
|
21
|
+
replace_host(comm, name, network_with_hostname[:ip])
|
22
|
+
else
|
23
|
+
add_hostname_to_loopback_interface(comm, name)
|
24
|
+
end
|
25
|
+
|
18
26
|
basename = name.split(".", 2)[0]
|
19
27
|
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
20
28
|
# Set the hostname
|
@@ -58,13 +66,6 @@ module VagrantPlugins
|
|
58
66
|
restart_each_interface(machine, @logger)
|
59
67
|
end
|
60
68
|
end
|
61
|
-
|
62
|
-
network_with_hostname = machine.config.vm.networks.map {|_, c| c if c[:hostname] }.compact[0]
|
63
|
-
if network_with_hostname
|
64
|
-
replace_host(comm, name, network_with_hostname[:ip])
|
65
|
-
else
|
66
|
-
add_hostname_to_loopback_interface(comm, name)
|
67
|
-
end
|
68
69
|
end
|
69
70
|
|
70
71
|
protected
|
@@ -9,44 +9,32 @@ module VagrantPlugins
|
|
9
9
|
|
10
10
|
extend SyncedFolder::UnixMountHelpers
|
11
11
|
|
12
|
+
# Mounts and SMB folder on linux guest
|
13
|
+
#
|
14
|
+
# @param [Machine] machine
|
15
|
+
# @param [String] name of mount
|
16
|
+
# @param [String] path of mount on guest
|
17
|
+
# @param [Hash] hash of mount options
|
12
18
|
def self.mount_smb_shared_folder(machine, name, guestpath, options)
|
13
19
|
expanded_guest_path = machine.guest.capability(
|
14
20
|
:shell_expand_guest_path, guestpath)
|
21
|
+
options[:smb_id] ||= name
|
15
22
|
|
16
|
-
mount_device
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
mount_uid = detected_ids[:uid]
|
21
|
-
mount_gid = detected_ids[:gid]
|
22
|
-
|
23
|
+
mount_device = options[:plugin].capability(:mount_name, options)
|
24
|
+
mount_options, _, _ = options[:plugin].capability(
|
25
|
+
:mount_options, name, expanded_guest_path, options)
|
26
|
+
mount_type = options[:plugin].capability(:mount_type)
|
23
27
|
# If a domain is provided in the username, separate it
|
24
28
|
username, domain = (options[:smb_username] || '').split('@', 2)
|
25
29
|
smb_password = options[:smb_password]
|
26
30
|
# Ensure password is scrubbed
|
27
31
|
Vagrant::Util::CredentialScrubber.sensitive(smb_password)
|
28
|
-
|
29
|
-
mnt_opts = []
|
30
|
-
if machine.env.host.capability?(:smb_mount_options)
|
31
|
-
mnt_opts += machine.env.host.capability(:smb_mount_options)
|
32
|
-
else
|
33
|
-
mnt_opts << "sec=ntlmssp"
|
34
|
-
end
|
35
|
-
mnt_opts << "credentials=/etc/smb_creds_#{name}"
|
36
|
-
mnt_opts << "uid=#{mount_uid}"
|
37
|
-
mnt_opts << "gid=#{mount_gid}"
|
38
|
-
if !ENV['VAGRANT_DISABLE_SMBMFSYMLINKS']
|
39
|
-
mnt_opts << "mfsymlinks"
|
40
|
-
end
|
41
|
-
|
42
|
-
mnt_opts = merge_mount_options(mnt_opts, options[:mount_options] || [])
|
43
|
-
|
44
|
-
mount_options = "-o #{mnt_opts.join(",")}"
|
32
|
+
|
45
33
|
if mount_options.include?("mfsymlinks")
|
46
34
|
display_mfsymlinks_warning(machine.env)
|
47
35
|
end
|
48
36
|
|
49
|
-
mount_command = "mount -t
|
37
|
+
mount_command = "mount -t #{mount_type} -o #{mount_options} #{mount_device} #{expanded_guest_path}"
|
50
38
|
|
51
39
|
# Create the guest path if it doesn't exist
|
52
40
|
machine.communicate.sudo("mkdir -p #{expanded_guest_path}")
|
@@ -82,27 +70,14 @@ SCRIPT
|
|
82
70
|
ensure
|
83
71
|
# Always remove credentials file after mounting attempts
|
84
72
|
# have been completed
|
85
|
-
machine.
|
73
|
+
if !machine.config.vm.allow_fstab_modification
|
74
|
+
machine.communicate.sudo("rm /etc/smb_creds_#{name}")
|
75
|
+
end
|
86
76
|
end
|
87
77
|
|
88
78
|
emit_upstart_notification(machine, expanded_guest_path)
|
89
79
|
end
|
90
80
|
|
91
|
-
def self.merge_mount_options(base, overrides)
|
92
|
-
base = base.join(",").split(",")
|
93
|
-
overrides = overrides.join(",").split(",")
|
94
|
-
b_kv = Hash[base.map{|item| item.split("=", 2) }]
|
95
|
-
o_kv = Hash[overrides.map{|item| item.split("=", 2) }]
|
96
|
-
merged = {}.tap do |opts|
|
97
|
-
(b_kv.keys + o_kv.keys).uniq.each do |key|
|
98
|
-
opts[key] = o_kv.fetch(key, b_kv[key])
|
99
|
-
end
|
100
|
-
end
|
101
|
-
merged.map do |key, value|
|
102
|
-
[key, value].compact.join("=")
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
81
|
def self.display_mfsymlinks_warning(env)
|
107
82
|
d_file = env.data_dir.join("mfsymlinks_warning")
|
108
83
|
if !d_file.exist?
|
@@ -6,6 +6,12 @@ module VagrantPlugins
|
|
6
6
|
class MountVirtualBoxSharedFolder
|
7
7
|
extend SyncedFolder::UnixMountHelpers
|
8
8
|
|
9
|
+
# Mounts and virtualbox folder on linux guest
|
10
|
+
#
|
11
|
+
# @param [Machine] machine
|
12
|
+
# @param [String] name of mount
|
13
|
+
# @param [String] path of mount on guest
|
14
|
+
# @param [Hash] hash of mount options
|
9
15
|
def self.mount_virtualbox_shared_folder(machine, name, guestpath, options)
|
10
16
|
guest_path = Shellwords.escape(guestpath)
|
11
17
|
mount_type = options[:plugin].capability(:mount_type)
|
@@ -8,6 +8,8 @@ module VagrantPlugins
|
|
8
8
|
class PersistMountSharedFolder
|
9
9
|
extend SyncedFolder::UnixMountHelpers
|
10
10
|
|
11
|
+
@@logger = Log4r::Logger.new("vagrant::guest::linux::persist_mount_shared_folders")
|
12
|
+
|
11
13
|
# Inserts fstab entry for a set of synced folders. Will fully replace
|
12
14
|
# the currently managed group of Vagrant managed entries. Note, passing
|
13
15
|
# empty list of folders will just remove entries
|
@@ -16,6 +18,7 @@ module VagrantPlugins
|
|
16
18
|
# @param [Map<String, Map>] A map of folders to add to fstab
|
17
19
|
def self.persist_mount_shared_folder(machine, folders)
|
18
20
|
if folders.nil?
|
21
|
+
@@logger.info("clearing /etc/fstab")
|
19
22
|
self.remove_vagrant_managed_fstab(machine)
|
20
23
|
return
|
21
24
|
end
|
@@ -23,14 +26,16 @@ module VagrantPlugins
|
|
23
26
|
ssh_info = machine.ssh_info
|
24
27
|
export_folders = folders.map { |type, folder|
|
25
28
|
folder.map { |name, data|
|
26
|
-
guest_path = Shellwords.escape(data[:guestpath])
|
27
|
-
data[:owner] ||= ssh_info[:username]
|
28
|
-
data[:group] ||= ssh_info[:username]
|
29
|
-
|
30
29
|
if data[:plugin].capability?(:mount_type)
|
30
|
+
guest_path = Shellwords.escape(data[:guestpath])
|
31
|
+
data[:owner] ||= ssh_info[:username]
|
32
|
+
data[:group] ||= ssh_info[:username]
|
31
33
|
mount_type = data[:plugin].capability(:mount_type)
|
32
34
|
mount_options, _, _ = data[:plugin].capability(
|
33
35
|
:mount_options, name, guest_path, data)
|
36
|
+
if data[:plugin].capability?(:mount_name)
|
37
|
+
name = data[:plugin].capability(:mount_name, data)
|
38
|
+
end
|
34
39
|
else
|
35
40
|
next
|
36
41
|
end
|
@@ -53,8 +58,16 @@ module VagrantPlugins
|
|
53
58
|
|
54
59
|
private
|
55
60
|
|
61
|
+
def self.fstab_exists?(machine)
|
62
|
+
machine.communicate.test("test -f /etc/fstab")
|
63
|
+
end
|
64
|
+
|
56
65
|
def self.remove_vagrant_managed_fstab(machine)
|
57
|
-
machine
|
66
|
+
if fstab_exists?(machine)
|
67
|
+
machine.communicate.sudo("sed -i '/\#VAGRANT-BEGIN/,/\#VAGRANT-END/d' /etc/fstab")
|
68
|
+
else
|
69
|
+
@@logger.info("no fstab file found, carrying on")
|
70
|
+
end
|
58
71
|
end
|
59
72
|
end
|
60
73
|
end
|
@@ -6,7 +6,9 @@ module VagrantPlugins
|
|
6
6
|
module Cap
|
7
7
|
class Reboot
|
8
8
|
extend Vagrant::Util::GuestInspection::Linux
|
9
|
-
|
9
|
+
|
10
|
+
DEFAULT_MAX_REBOOT_RETRY_DURATION = 120
|
11
|
+
WAIT_SLEEP_TIME = 5
|
10
12
|
|
11
13
|
def self.reboot(machine)
|
12
14
|
@logger = Log4r::Logger.new("vagrant::linux::reboot")
|
@@ -25,14 +27,17 @@ module VagrantPlugins
|
|
25
27
|
|
26
28
|
@logger.debug("Waiting for machine to finish rebooting")
|
27
29
|
|
28
|
-
wait_remaining =
|
30
|
+
wait_remaining = ENV.fetch("VAGRANT_MAX_REBOOT_RETRY_DURATION",
|
31
|
+
DEFAULT_MAX_REBOOT_RETRY_DURATION).to_i
|
32
|
+
wait_remaining = DEFAULT_MAX_REBOOT_RETRY_DURATION if wait_remaining < 1
|
33
|
+
|
29
34
|
begin
|
30
35
|
wait_for_reboot(machine)
|
31
|
-
rescue Vagrant::Errors::MachineGuestNotReady
|
36
|
+
rescue Vagrant::Errors::MachineGuestNotReady
|
32
37
|
raise if wait_remaining < 0
|
33
38
|
@logger.warn("Machine not ready, cannot start reboot yet. Trying again")
|
34
|
-
sleep(
|
35
|
-
wait_remaining -=
|
39
|
+
sleep(WAIT_SLEEP_TIME)
|
40
|
+
wait_remaining -= WAIT_SLEEP_TIME
|
36
41
|
retry
|
37
42
|
end
|
38
43
|
end
|
@@ -15,9 +15,13 @@ module VagrantPlugins
|
|
15
15
|
basename = name.split('.', 2)[0]
|
16
16
|
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
17
17
|
# Update sysconfig
|
18
|
-
|
18
|
+
if [ -f /etc/sysconfig/network ]; then
|
19
|
+
sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network
|
20
|
+
fi
|
19
21
|
# Update DNS
|
20
|
-
sed -i 's/\\(DHCP_HOSTNAME=\\).*/\\1\"#{basename}\"/'
|
22
|
+
find /etc/sysconfig/network-scripts -maxdepth 1 -type f -name 'ifcfg-*' | xargs -r sed -i 's/\\(DHCP_HOSTNAME=\\).*/\\1\"#{basename}\"/'
|
23
|
+
# Set the hostname - use hostnamectl if available
|
24
|
+
echo '#{name}' > /etc/hostname
|
21
25
|
EOH
|
22
26
|
|
23
27
|
if hostnamectl?(comm)
|
@@ -1,22 +1,43 @@
|
|
1
|
-
|
1
|
+
require 'vagrant/util/guest_hosts'
|
2
|
+
require 'vagrant/util/guest_inspection'
|
2
3
|
|
3
4
|
module VagrantPlugins
|
4
5
|
module GuestSUSE
|
5
6
|
module Cap
|
6
7
|
class ChangeHostName
|
7
|
-
extend VagrantPlugins::GuestLinux::Cap::ChangeHostName
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
!comm.test("test \"$(hostnamectl --static status)\" = \"#{basename}\"", sudo: false)
|
12
|
-
end
|
9
|
+
extend Vagrant::Util::GuestInspection::Linux
|
10
|
+
extend Vagrant::Util::GuestHosts::Linux
|
13
11
|
|
14
|
-
def self.
|
12
|
+
def self.change_host_name(machine, name)
|
13
|
+
comm = machine.communicate
|
15
14
|
basename = name.split(".", 2)[0]
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
|
16
|
+
network_with_hostname = machine.config.vm.networks.map {|_, c| c if c[:hostname] }.compact[0]
|
17
|
+
if network_with_hostname
|
18
|
+
replace_host(comm, name, network_with_hostname[:ip])
|
19
|
+
else
|
20
|
+
add_hostname_to_loopback_interface(comm, name)
|
21
|
+
end
|
22
|
+
|
23
|
+
if hostnamectl?(comm)
|
24
|
+
if !comm.test("test \"$(hostnamectl --static status)\" = \"#{basename}\"", sudo: false)
|
25
|
+
cmd = <<-EOH.gsub(/^ {14}/, "")
|
26
|
+
hostnamectl set-hostname '#{basename}'
|
27
|
+
echo #{name} > /etc/HOSTNAME
|
28
|
+
EOH
|
29
|
+
comm.sudo(cmd)
|
30
|
+
end
|
31
|
+
else
|
32
|
+
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
|
33
|
+
cmd = <<-EOH.gsub(/^ {14}/, "")
|
34
|
+
echo #{name} > /etc/HOSTNAME
|
35
|
+
hostname '#{basename}'
|
36
|
+
EOH
|
37
|
+
comm.sudo(cmd)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
20
41
|
end
|
21
42
|
end
|
22
43
|
end
|
@@ -4,7 +4,8 @@ module VagrantPlugins
|
|
4
4
|
module GuestWindows
|
5
5
|
module Cap
|
6
6
|
class Reboot
|
7
|
-
|
7
|
+
DEFAULT_MAX_REBOOT_RETRY_DURATION = 120
|
8
|
+
WAIT_SLEEP_TIME = 5
|
8
9
|
|
9
10
|
def self.reboot(machine)
|
10
11
|
@logger = Log4r::Logger.new("vagrant::windows::reboot")
|
@@ -25,15 +26,18 @@ module VagrantPlugins
|
|
25
26
|
|
26
27
|
@logger.debug("Waiting for machine to finish rebooting")
|
27
28
|
|
28
|
-
wait_remaining =
|
29
|
+
wait_remaining = ENV.fetch("VAGRANT_MAX_REBOOT_RETRY_DURATION",
|
30
|
+
DEFAULT_MAX_REBOOT_RETRY_DURATION).to_i
|
31
|
+
wait_remaining = DEFAULT_MAX_REBOOT_RETRY_DURATION if wait_remaining < 1
|
32
|
+
|
29
33
|
begin
|
30
34
|
wait_for_reboot(machine)
|
31
35
|
rescue => err
|
32
36
|
raise if wait_remaining < 0
|
33
37
|
@logger.debug("Exception caught while waiting for reboot: #{err}")
|
34
38
|
@logger.warn("Machine not ready, cannot start reboot yet. Trying again")
|
35
|
-
sleep(
|
36
|
-
wait_remaining -=
|
39
|
+
sleep(WAIT_SLEEP_TIME)
|
40
|
+
wait_remaining -= WAIT_SLEEP_TIME
|
37
41
|
retry
|
38
42
|
end
|
39
43
|
end
|