vagrant-unbundled 2.2.9.0 → 2.2.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +60 -0
  3. data/README.md +5 -5
  4. data/contrib/README.md +1 -0
  5. data/contrib/sudoers/linux-suse +2 -2
  6. data/contrib/zsh/_vagrant +736 -0
  7. data/contrib/zsh/generate_zsh_completion.rb +166 -0
  8. data/lib/vagrant/action.rb +3 -0
  9. data/lib/vagrant/action/builder.rb +52 -18
  10. data/lib/vagrant/action/builtin/box_add.rb +6 -5
  11. data/lib/vagrant/action/builtin/cloud_init_setup.rb +127 -0
  12. data/lib/vagrant/action/builtin/cloud_init_wait.rb +30 -0
  13. data/lib/vagrant/action/builtin/handle_box.rb +1 -1
  14. data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +13 -13
  15. data/lib/vagrant/action/builtin/has_provisioner.rb +36 -0
  16. data/lib/vagrant/action/builtin/mixin_provisioners.rb +1 -0
  17. data/lib/vagrant/action/builtin/mixin_synced_folders.rb +20 -21
  18. data/lib/vagrant/action/builtin/set_hostname.rb +5 -1
  19. data/lib/vagrant/action/builtin/synced_folders.rb +10 -0
  20. data/lib/vagrant/action/builtin/trigger.rb +3 -2
  21. data/lib/vagrant/action/hook.rb +59 -24
  22. data/lib/vagrant/action/warden.rb +25 -5
  23. data/lib/vagrant/box.rb +5 -4
  24. data/lib/vagrant/bundler.rb +6 -1
  25. data/lib/vagrant/errors.rb +37 -1
  26. data/lib/vagrant/machine.rb +47 -0
  27. data/lib/vagrant/machine_index.rb +27 -1
  28. data/lib/vagrant/plugin/v2/command.rb +5 -1
  29. data/lib/vagrant/plugin/v2/components.rb +6 -0
  30. data/lib/vagrant/plugin/v2/manager.rb +14 -0
  31. data/lib/vagrant/plugin/v2/plugin.rb +12 -0
  32. data/lib/vagrant/plugin/v2/synced_folder.rb +50 -0
  33. data/lib/vagrant/plugin/v2/trigger.rb +6 -5
  34. data/lib/vagrant/ui.rb +1 -1
  35. data/lib/vagrant/util/ansi_escape_code_remover.rb +1 -1
  36. data/lib/vagrant/util/caps.rb +48 -0
  37. data/lib/vagrant/util/credential_scrubber.rb +1 -1
  38. data/lib/vagrant/util/directory.rb +19 -0
  39. data/lib/vagrant/util/downloader.rb +3 -3
  40. data/lib/vagrant/util/guest_hosts.rb +68 -0
  41. data/lib/vagrant/util/install_cli_autocomplete.rb +118 -0
  42. data/lib/vagrant/util/ipv4_interfaces.rb +15 -0
  43. data/lib/vagrant/util/is_port_open.rb +8 -19
  44. data/lib/vagrant/util/network_ip.rb +11 -1
  45. data/lib/vagrant/util/powershell.rb +1 -1
  46. data/lib/vagrant/util/subprocess.rb +9 -1
  47. data/lib/vagrant/vagrantfile.rb +1 -1
  48. data/plugins/commands/autocomplete/command/install.rb +49 -0
  49. data/plugins/commands/autocomplete/command/root.rb +64 -0
  50. data/plugins/commands/autocomplete/plugin.rb +18 -0
  51. data/plugins/commands/destroy/command.rb +6 -2
  52. data/plugins/communicators/ssh/communicator.rb +7 -1
  53. data/plugins/communicators/winrm/helper.rb +1 -1
  54. data/plugins/communicators/winssh/communicator.rb +1 -1
  55. data/plugins/guests/alpine/cap/change_host_name.rb +10 -11
  56. data/plugins/guests/alt/cap/change_host_name.rb +40 -53
  57. data/plugins/guests/arch/cap/change_host_name.rb +5 -14
  58. data/plugins/guests/arch/cap/configure_networks.rb +27 -10
  59. data/plugins/guests/atomic/cap/change_host_name.rb +5 -14
  60. data/plugins/guests/darwin/cap/change_host_name.rb +10 -6
  61. data/plugins/guests/debian/cap/change_host_name.rb +11 -11
  62. data/plugins/guests/esxi/cap/public_key.rb +3 -1
  63. data/plugins/guests/freebsd/cap/change_host_name.rb +10 -6
  64. data/plugins/guests/gentoo/cap/change_host_name.rb +14 -22
  65. data/plugins/guests/haiku/cap/rsync.rb +19 -0
  66. data/plugins/guests/haiku/plugin.rb +15 -0
  67. data/plugins/guests/linux/cap/change_host_name.rb +46 -0
  68. data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +4 -11
  69. data/plugins/guests/linux/cap/persist_mount_shared_folder.rb +62 -0
  70. data/plugins/guests/linux/plugin.rb +10 -0
  71. data/plugins/guests/omnios/cap/change_host_name.rb +10 -16
  72. data/plugins/guests/openbsd/cap/change_host_name.rb +10 -6
  73. data/plugins/guests/photon/cap/change_host_name.rb +9 -15
  74. data/plugins/guests/pld/cap/change_host_name.rb +11 -17
  75. data/plugins/guests/redhat/cap/change_host_name.rb +10 -5
  76. data/plugins/guests/slackware/cap/change_host_name.rb +11 -17
  77. data/plugins/guests/solaris11/plugin.rb +5 -0
  78. data/plugins/guests/suse/cap/change_host_name.rb +12 -11
  79. data/plugins/hosts/darwin/cap/fs_iso.rb +49 -0
  80. data/plugins/hosts/darwin/plugin.rb +10 -0
  81. data/plugins/hosts/linux/cap/fs_iso.rb +49 -0
  82. data/plugins/hosts/linux/cap/rdp.rb +1 -1
  83. data/plugins/hosts/linux/plugin.rb +10 -0
  84. data/plugins/hosts/windows/cap/fs_iso.rb +48 -0
  85. data/plugins/hosts/windows/cap/rdp.rb +1 -1
  86. data/plugins/hosts/windows/plugin.rb +15 -0
  87. data/plugins/kernel_v2/config/cloud_init.rb +126 -0
  88. data/plugins/kernel_v2/config/disk.rb +40 -18
  89. data/plugins/kernel_v2/config/vm.rb +122 -13
  90. data/plugins/kernel_v2/config/vm_provisioner.rb +13 -2
  91. data/plugins/kernel_v2/config/vm_trigger.rb +5 -1
  92. data/plugins/providers/docker/action.rb +8 -17
  93. data/plugins/providers/docker/action/forwarded_ports.rb +2 -0
  94. data/plugins/providers/docker/action/prepare_forwarded_port_collision_params.rb +61 -0
  95. data/plugins/providers/docker/cap/has_communicator.rb +11 -0
  96. data/plugins/providers/docker/communicator.rb +1 -1
  97. data/plugins/providers/docker/driver.rb +35 -0
  98. data/plugins/providers/docker/plugin.rb +5 -0
  99. data/plugins/providers/hyperv/action.rb +2 -0
  100. data/plugins/providers/hyperv/action/configure.rb +8 -0
  101. data/plugins/providers/hyperv/cap/cleanup_disks.rb +54 -0
  102. data/plugins/providers/hyperv/cap/configure_disks.rb +200 -0
  103. data/plugins/providers/hyperv/cap/validate_disk_ext.rb +34 -0
  104. data/plugins/providers/hyperv/config.rb +5 -0
  105. data/plugins/providers/hyperv/driver.rb +80 -0
  106. data/plugins/providers/hyperv/plugin.rb +25 -0
  107. data/plugins/providers/hyperv/scripts/attach_disk_drive.ps1 +28 -0
  108. data/plugins/providers/hyperv/scripts/dismount_vhd.ps1 +13 -0
  109. data/plugins/providers/hyperv/scripts/get_vhd.ps1 +16 -0
  110. data/plugins/providers/hyperv/scripts/get_vm_status.ps1 +1 -1
  111. data/plugins/providers/hyperv/scripts/list_hdds.ps1 +17 -0
  112. data/plugins/providers/hyperv/scripts/new_vhd.ps1 +31 -0
  113. data/plugins/providers/hyperv/scripts/remove_disk_drive.ps1 +25 -0
  114. data/plugins/providers/hyperv/scripts/resize_disk_drive.ps1 +18 -0
  115. data/plugins/providers/hyperv/scripts/set_enhanced_session_transport_type.ps1 +24 -0
  116. data/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 +8 -0
  117. data/plugins/providers/virtualbox/action.rb +12 -1
  118. data/plugins/providers/virtualbox/action/forward_ports.rb +2 -2
  119. data/plugins/providers/virtualbox/cap/cleanup_disks.rb +40 -9
  120. data/plugins/providers/virtualbox/cap/configure_disks.rb +230 -77
  121. data/plugins/providers/virtualbox/cap/mount_options.rb +35 -0
  122. data/plugins/providers/virtualbox/cap/validate_disk_ext.rb +10 -3
  123. data/plugins/providers/virtualbox/driver/meta.rb +3 -0
  124. data/plugins/providers/virtualbox/driver/version_5_0.rb +96 -21
  125. data/plugins/providers/virtualbox/model/storage_controller.rb +135 -0
  126. data/plugins/providers/virtualbox/model/storage_controller_array.rb +100 -0
  127. data/plugins/providers/virtualbox/plugin.rb +18 -1
  128. data/plugins/providers/virtualbox/synced_folder.rb +1 -0
  129. data/plugins/provisioners/container/client.rb +1 -1
  130. data/plugins/provisioners/shell/provisioner.rb +15 -9
  131. data/plugins/synced_folders/nfs/synced_folder.rb +3 -1
  132. data/plugins/synced_folders/smb/cap/default_fstab_modification.rb +11 -0
  133. data/plugins/synced_folders/smb/cap/mount_options.rb +36 -0
  134. data/plugins/synced_folders/smb/plugin.rb +10 -0
  135. data/plugins/synced_folders/smb/synced_folder.rb +1 -1
  136. data/plugins/synced_folders/unix_mount_helpers.rb +14 -0
  137. data/templates/guests/arch/{network_dhcp.erb → default_network/network_dhcp.erb} +0 -0
  138. data/templates/guests/arch/{network_static.erb → default_network/network_static.erb} +0 -0
  139. data/templates/guests/arch/{network_static6.erb → default_network/network_static6.erb} +0 -0
  140. data/templates/guests/arch/systemd_networkd/network_dhcp.erb +6 -0
  141. data/templates/guests/arch/systemd_networkd/network_static.erb +9 -0
  142. data/templates/guests/arch/systemd_networkd/network_static6.erb +9 -0
  143. data/templates/guests/linux/etc_fstab.erb +6 -0
  144. data/templates/locales/en.yml +121 -11
  145. data/templates/locales/providers_docker.yml +4 -0
  146. data/vagrant.gemspec +8 -7
  147. data/version.txt +1 -1
  148. metadata +1492 -1309
@@ -1,4 +1,5 @@
1
1
  require "log4r"
2
+ require 'vagrant/util/guest_hosts'
2
3
  require_relative "../../linux/cap/network_interfaces"
3
4
 
4
5
  module VagrantPlugins
@@ -7,6 +8,7 @@ module VagrantPlugins
7
8
  class ChangeHostName
8
9
 
9
10
  extend Vagrant::Util::GuestInspection::Linux
11
+ extend Vagrant::Util::GuestHosts::Linux
10
12
 
11
13
  def self.change_host_name(machine, name)
12
14
  @logger = Log4r::Logger.new("vagrant::guest::debian::changehostname")
@@ -18,15 +20,6 @@ module VagrantPlugins
18
20
  # Set the hostname
19
21
  echo '#{basename}' > /etc/hostname
20
22
 
21
- # Prepend ourselves to /etc/hosts
22
- grep -w '#{name}' /etc/hosts || {
23
- if grep -w '^127\\.0\\.1\\.1' /etc/hosts ; then
24
- sed -i'' 's/^127\\.0\\.1\\.1\\s.*$/127.0.1.1\\t#{name}\\t#{basename}/' /etc/hosts
25
- else
26
- sed -i'' '1i 127.0.1.1\\t#{name}\\t#{basename}' /etc/hosts
27
- fi
28
- }
29
-
30
23
  # Update mailname
31
24
  echo '#{name}' > /etc/mailname
32
25
 
@@ -65,6 +58,13 @@ module VagrantPlugins
65
58
  restart_each_interface(machine, @logger)
66
59
  end
67
60
  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
68
  end
69
69
 
70
70
  protected
@@ -83,10 +83,10 @@ module VagrantPlugins
83
83
  interfaces = VagrantPlugins::GuestLinux::Cap::NetworkInterfaces.network_interfaces(machine)
84
84
  nettools = true
85
85
  if systemd?(comm)
86
- @logger.debug("Attempting to restart networking with systemctl")
86
+ logger.debug("Attempting to restart networking with systemctl")
87
87
  nettools = false
88
88
  else
89
- @logger.debug("Attempting to restart networking with ifup/down nettools")
89
+ logger.debug("Attempting to restart networking with ifup/down nettools")
90
90
  end
91
91
 
92
92
  interfaces.each do |iface|
@@ -24,7 +24,9 @@ module VagrantPlugins
24
24
  set -e
25
25
  SSH_DIR="$(grep -q '^AuthorizedKeysFile\s*\/etc\/ssh\/keys-%u\/authorized_keys$' /etc/ssh/sshd_config && echo -n /etc/ssh/keys-${USER} || echo -n ~/.ssh)"
26
26
  mkdir -p "${SSH_DIR}"
27
- chmod 0700 "${SSH_DIR}"
27
+ # NB in ESXi 7.0 we cannot change the /etc/ssh/keys-root directory
28
+ # permissions, so ignore any errors.
29
+ chmod 0700 "${SSH_DIR}" || true
28
30
  cat '#{remote_path}' >> "${SSH_DIR}/authorized_keys"
29
31
  chmod 0600 "${SSH_DIR}/authorized_keys"
30
32
  rm -f '#{remote_path}'
@@ -1,7 +1,11 @@
1
+ require 'vagrant/util/guest_hosts'
2
+
1
3
  module VagrantPlugins
2
4
  module GuestFreeBSD
3
5
  module Cap
4
6
  class ChangeHostName
7
+ extend Vagrant::Util::GuestHosts::BSD
8
+
5
9
  def self.change_host_name(machine, name)
6
10
  comm = machine.communicate
7
11
 
@@ -11,15 +15,15 @@ module VagrantPlugins
11
15
  # Set the hostname
12
16
  hostname '#{name}'
13
17
  sed -i '' 's/^hostname=.*$/hostname=\"#{name}\"/' /etc/rc.conf
14
-
15
- # Prepend ourselves to /etc/hosts
16
- grep -w '#{name}' /etc/hosts || {
17
- echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts
18
- mv /tmp/tmp-hosts /etc/hosts
19
- }
20
18
  EOH
21
19
  comm.sudo(command, shell: "sh")
22
20
  end
21
+ network_with_hostname = machine.config.vm.networks.map {|_, c| c if c[:hostname] }.compact[0]
22
+ if network_with_hostname
23
+ replace_host(comm, name, network_with_hostname[:ip])
24
+ else
25
+ add_hostname_to_loopback_interface(comm, name)
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -1,30 +1,22 @@
1
+ require_relative '../../linux/cap/change_host_name'
2
+
1
3
  module VagrantPlugins
2
4
  module GuestGentoo
3
5
  module Cap
4
6
  class ChangeHostName
5
- def self.change_host_name(machine, name)
6
- comm = machine.communicate
7
-
8
- if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
9
- basename = name.split(".", 2)[0]
10
- comm.sudo <<-EOH.gsub(/^ {14}/, "")
11
- # Set the hostname
12
-
13
- # Use hostnamectl on systemd
14
- if [[ `systemctl` =~ -\.mount ]]; then
15
- systemctl set-hostname '#{name}'
16
- else
17
- hostname '#{basename}'
18
- echo "hostname=#{basename}" > /etc/conf.d/hostname
19
- fi
7
+ extend VagrantPlugins::GuestLinux::Cap::ChangeHostName
20
8
 
21
- # Prepend ourselves to /etc/hosts
22
- grep -w '#{name}' /etc/hosts || {
23
- echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts &&
24
- mv /tmp/tmp-hosts /etc/hosts
25
- }
26
- EOH
27
- end
9
+ def self.change_name_command(name)
10
+ basename = name.split(".", 2)[0]
11
+ return <<-EOH.gsub(/^ {14}/, '')
12
+ # Use hostnamectl on systemd
13
+ if [[ `systemctl` =~ -\.mount ]]; then
14
+ systemctl set-hostname '#{name}'
15
+ else
16
+ hostname '#{basename}'
17
+ echo "hostname=#{basename}" > /etc/conf.d/hostname
18
+ fi
19
+ EOH
28
20
  end
29
21
  end
30
22
  end
@@ -0,0 +1,19 @@
1
+ module VagrantPlugins
2
+ module GuestHaiku
3
+ module Cap
4
+ class RSync
5
+ def self.rsync_installed(machine)
6
+ machine.communicate.test("test -f /bin/rsync")
7
+ end
8
+
9
+ def self.rsync_install(machine)
10
+ machine.communicate.execute("pkgman install -y rsync")
11
+ end
12
+
13
+ def self.rsync_command(machine)
14
+ "rsync -zz"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -30,6 +30,21 @@ module VagrantPlugins
30
30
  require_relative "cap/remove_public_key"
31
31
  Cap::RemovePublicKey
32
32
  end
33
+
34
+ guest_capability(:haiku, :rsync_install) do
35
+ require_relative "cap/rsync"
36
+ Cap::RSync
37
+ end
38
+
39
+ guest_capability(:haiku, :rsync_installed) do
40
+ require_relative "cap/rsync"
41
+ Cap::RSync
42
+ end
43
+
44
+ guest_capability(:haiku, :rsync_command) do
45
+ require_relative "cap/rsync"
46
+ Cap::RSync
47
+ end
33
48
  end
34
49
  end
35
50
  end
@@ -0,0 +1,46 @@
1
+ require 'vagrant/util/guest_hosts'
2
+
3
+ module VagrantPlugins
4
+ module GuestLinux
5
+ module Cap
6
+ module ChangeHostName
7
+ module Methods
8
+ def change_name_command(name)
9
+ return <<-EOH.gsub(/^ {14}/, '')
10
+ # Set the hostname
11
+ echo '#{name}' > /etc/hostname
12
+ hostname '#{name}'
13
+ EOH
14
+ end
15
+
16
+ def change_host_name?(comm, name)
17
+ !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
18
+ end
19
+
20
+ def change_host_name(machine, name)
21
+ comm = machine.communicate
22
+
23
+ network_with_hostname = machine.config.vm.networks.map {|_, c| c if c[:hostname] }.compact[0]
24
+ if network_with_hostname
25
+ replace_host(comm, name, network_with_hostname[:ip])
26
+ else
27
+ add_hostname_to_loopback_interface(comm, name)
28
+ end
29
+
30
+ if change_host_name?(comm, name)
31
+ comm.sudo(change_name_command(name))
32
+ end
33
+ end
34
+ end
35
+
36
+ def self.extended(klass)
37
+ klass.extend(Vagrant::Util::GuestHosts::Linux)
38
+ klass.extend(Methods)
39
+ end
40
+
41
+ extend Vagrant::Util::GuestHosts::Linux
42
+ extend Methods
43
+ end
44
+ end
45
+ end
46
+ end
@@ -8,20 +8,14 @@ module VagrantPlugins
8
8
 
9
9
  def self.mount_virtualbox_shared_folder(machine, name, guestpath, options)
10
10
  guest_path = Shellwords.escape(guestpath)
11
+ mount_type = options[:plugin].capability(:mount_type)
11
12
 
12
13
  @@logger.debug("Mounting #{name} (#{options[:hostpath]} to #{guestpath})")
13
14
 
14
- builtin_mount_type = "-cit vboxsf"
15
- addon_mount_type = "-t vboxsf"
15
+ builtin_mount_type = "-cit #{mount_type}"
16
+ addon_mount_type = "-t #{mount_type}"
16
17
 
17
- mount_options = options.fetch(:mount_options, [])
18
- detected_ids = detect_owner_group_ids(machine, guest_path, mount_options, options)
19
- mount_uid = detected_ids[:uid]
20
- mount_gid = detected_ids[:gid]
21
-
22
- mount_options << "uid=#{mount_uid}"
23
- mount_options << "gid=#{mount_gid}"
24
- mount_options = mount_options.join(',')
18
+ mount_options, mount_uid, mount_gid = options[:plugin].capability(:mount_options, name, guest_path, options)
25
19
  mount_command = "mount #{addon_mount_type} -o #{mount_options} #{name} #{guest_path}"
26
20
 
27
21
  # Create the guest path if it doesn't exist
@@ -61,7 +55,6 @@ module VagrantPlugins
61
55
  emit_upstart_notification(machine, guest_path)
62
56
  end
63
57
 
64
-
65
58
  def self.unmount_virtualbox_shared_folder(machine, guestpath, options)
66
59
  guest_path = Shellwords.escape(guestpath)
67
60
 
@@ -0,0 +1,62 @@
1
+ require "vagrant/util"
2
+
3
+ require_relative "../../../synced_folders/unix_mount_helpers"
4
+
5
+ module VagrantPlugins
6
+ module GuestLinux
7
+ module Cap
8
+ class PersistMountSharedFolder
9
+ extend SyncedFolder::UnixMountHelpers
10
+
11
+ # Inserts fstab entry for a set of synced folders. Will fully replace
12
+ # the currently managed group of Vagrant managed entries. Note, passing
13
+ # empty list of folders will just remove entries
14
+ #
15
+ # @param [Machine] machine The machine to run the action on
16
+ # @param [Map<String, Map>] A map of folders to add to fstab
17
+ def self.persist_mount_shared_folder(machine, folders)
18
+ if folders.nil?
19
+ self.remove_vagrant_managed_fstab(machine)
20
+ return
21
+ end
22
+
23
+ ssh_info = machine.ssh_info
24
+ export_folders = folders.map { |type, folder|
25
+ 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
+ if data[:plugin].capability?(:mount_type)
31
+ mount_type = data[:plugin].capability(:mount_type)
32
+ mount_options, _, _ = data[:plugin].capability(
33
+ :mount_options, name, guest_path, data)
34
+ else
35
+ next
36
+ end
37
+
38
+ mount_options = "#{mount_options},nofail"
39
+ {
40
+ name: name,
41
+ mount_point: guest_path,
42
+ mount_type: mount_type,
43
+ mount_options: mount_options,
44
+ }
45
+ }
46
+ }.flatten.compact
47
+
48
+
49
+ fstab_entry = Vagrant::Util::TemplateRenderer.render('guests/linux/etc_fstab', folders: export_folders)
50
+ self.remove_vagrant_managed_fstab(machine)
51
+ machine.communicate.sudo("echo '#{fstab_entry}' >> /etc/fstab")
52
+ end
53
+
54
+ private
55
+
56
+ def self.remove_vagrant_managed_fstab(machine)
57
+ machine.communicate.sudo("sed -i '/\#VAGRANT-BEGIN/,/\#VAGRANT-END/d' /etc/fstab")
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -11,6 +11,11 @@ module VagrantPlugins
11
11
  Guest
12
12
  end
13
13
 
14
+ guest_capability(:linux, :change_host_name) do
15
+ require_relative "cap/change_host_name"
16
+ Cap::ChangeHostName
17
+ end
18
+
14
19
  guest_capability(:linux, :choose_addressable_ip_addr) do
15
20
  require_relative "cap/choose_addressable_ip_addr"
16
21
  Cap::ChooseAddressableIPAddr
@@ -61,6 +66,11 @@ module VagrantPlugins
61
66
  Cap::MountVirtualBoxSharedFolder
62
67
  end
63
68
 
69
+ guest_capability(:linux, :persist_mount_shared_folder) do
70
+ require_relative "cap/persist_mount_shared_folder"
71
+ Cap::PersistMountSharedFolder
72
+ end
73
+
64
74
  guest_capability(:linux, :network_interfaces) do
65
75
  require_relative "cap/network_interfaces"
66
76
  Cap::NetworkInterfaces
@@ -1,24 +1,18 @@
1
+ require_relative '../../linux/cap/change_host_name'
2
+
1
3
  module VagrantPlugins
2
4
  module GuestOmniOS
3
5
  module Cap
4
6
  class ChangeHostName
5
- def self.change_host_name(machine, name)
6
- comm = machine.communicate
7
-
8
- if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
9
- basename = name.split(".", 2)[0]
10
- comm.sudo <<-EOH.gsub(/^ {14}/, '')
11
- # Set hostname
12
- echo '#{name}' > /etc/nodename
13
- hostname '#{name}'
7
+ extend VagrantPlugins::GuestLinux::Cap::ChangeHostName
14
8
 
15
- # Prepend ourselves to /etc/hosts
16
- grep -w '#{name}' /etc/hosts || {
17
- echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts
18
- mv /tmp/tmp-hosts /etc/hosts
19
- }
20
- EOH
21
- end
9
+ def self.change_name_command(name)
10
+ basename = name.split(".", 2)[0]
11
+ return <<-EOH.gsub(/^ {14}/, "")
12
+ # Set hostname
13
+ echo '#{name}' > /etc/nodename
14
+ hostname '#{name}'
15
+ EOH
22
16
  end
23
17
  end
24
18
  end
@@ -1,7 +1,11 @@
1
+ require 'vagrant/util/guest_hosts'
2
+
1
3
  module VagrantPlugins
2
4
  module GuestOpenBSD
3
5
  module Cap
4
6
  class ChangeHostName
7
+ extend Vagrant::Util::GuestHosts::BSD
8
+
5
9
  def self.change_host_name(machine, name)
6
10
  comm = machine.communicate
7
11
 
@@ -12,15 +16,15 @@ module VagrantPlugins
12
16
  hostname '#{name}'
13
17
  sed -i'' 's/^hostname=.*$/hostname=\"#{name}\"/' /etc/rc.conf
14
18
  echo '#{name}' > /etc/myname
15
-
16
- # Prepend ourselves to /etc/hosts
17
- grep -w '#{name}' /etc/hosts || {
18
- echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts
19
- mv /tmp/tmp-hosts /etc/hosts
20
- }
21
19
  EOH
22
20
  comm.sudo(command, shell: "sh")
23
21
  end
22
+ network_with_hostname = machine.config.vm.networks.map {|_, c| c if c[:hostname] }.compact[0]
23
+ if network_with_hostname
24
+ replace_host(comm, name, network_with_hostname[:ip])
25
+ else
26
+ add_hostname_to_loopback_interface(comm, name)
27
+ end
24
28
  end
25
29
  end
26
30
  end
@@ -1,23 +1,17 @@
1
+ require_relative '../../linux/cap/change_host_name'
2
+
1
3
  module VagrantPlugins
2
4
  module GuestPhoton
3
5
  module Cap
4
6
  class ChangeHostName
5
- def self.change_host_name(machine, name)
6
- comm = machine.communicate
7
-
8
- if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
9
- basename = name.split(".", 2)[0]
10
- comm.sudo <<-EOH.gsub(/^ {14}/, '')
11
- # Set the hostname
12
- echo '#{name}' > /etc/hostname
13
- hostname '#{name}'
7
+ extend VagrantPlugins::GuestLinux::Cap::ChangeHostName
14
8
 
15
- # Prepend ourselves to /etc/hosts
16
- grep -w '#{name}' /etc/hosts || {
17
- sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
18
- }
19
- EOH
20
- end
9
+ def self.change_name_command(name)
10
+ return <<-EOH.gsub(/^ {14}/, "")
11
+ # Set the hostname
12
+ echo '#{name}' > /etc/hostname
13
+ hostname '#{name}'
14
+ EOH
21
15
  end
22
16
  end
23
17
  end