vagrant-unbundled 2.2.6.1 → 2.2.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. checksums.yaml +4 -4
  2. data/.hashibot.hcl +14 -0
  3. data/CHANGELOG.md +153 -2
  4. data/README.md +5 -7
  5. data/bin/vagrant +23 -0
  6. data/contrib/README.md +1 -0
  7. data/contrib/bash/completion.sh +13 -1
  8. data/contrib/sudoers/linux-suse +2 -2
  9. data/contrib/zsh/_vagrant +736 -0
  10. data/contrib/zsh/generate_zsh_completion.rb +166 -0
  11. data/lib/vagrant.rb +25 -0
  12. data/lib/vagrant/action.rb +8 -0
  13. data/lib/vagrant/action/builder.rb +193 -38
  14. data/lib/vagrant/action/builtin/box_add.rb +15 -7
  15. data/lib/vagrant/action/builtin/box_check_outdated.rb +12 -15
  16. data/lib/vagrant/action/builtin/cleanup_disks.rb +56 -0
  17. data/lib/vagrant/action/builtin/cloud_init_setup.rb +127 -0
  18. data/lib/vagrant/action/builtin/cloud_init_wait.rb +30 -0
  19. data/lib/vagrant/action/builtin/delayed.rb +26 -0
  20. data/lib/vagrant/action/builtin/disk.rb +52 -0
  21. data/lib/vagrant/action/builtin/handle_box.rb +3 -1
  22. data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +28 -9
  23. data/lib/vagrant/action/builtin/has_provisioner.rb +36 -0
  24. data/lib/vagrant/action/builtin/mixin_provisioners.rb +20 -1
  25. data/lib/vagrant/action/builtin/mixin_synced_folders.rb +20 -21
  26. data/lib/vagrant/action/builtin/set_hostname.rb +5 -1
  27. data/lib/vagrant/action/builtin/ssh_run.rb +21 -3
  28. data/lib/vagrant/action/builtin/synced_folders.rb +10 -0
  29. data/lib/vagrant/action/builtin/trigger.rb +37 -0
  30. data/lib/vagrant/action/hook.rb +76 -23
  31. data/lib/vagrant/action/runner.rb +11 -26
  32. data/lib/vagrant/action/warden.rb +28 -22
  33. data/lib/vagrant/box.rb +5 -4
  34. data/lib/vagrant/box_metadata.rb +17 -3
  35. data/lib/vagrant/bundler.rb +265 -53
  36. data/lib/vagrant/cli.rb +4 -2
  37. data/lib/vagrant/errors.rb +61 -1
  38. data/lib/vagrant/machine.rb +56 -6
  39. data/lib/vagrant/machine_index.rb +27 -1
  40. data/lib/vagrant/plugin/manager.rb +25 -14
  41. data/lib/vagrant/plugin/v2/command.rb +6 -2
  42. data/lib/vagrant/plugin/v2/components.rb +6 -0
  43. data/lib/vagrant/plugin/v2/manager.rb +67 -0
  44. data/lib/vagrant/plugin/v2/plugin.rb +13 -0
  45. data/lib/vagrant/plugin/v2/synced_folder.rb +50 -0
  46. data/lib/vagrant/plugin/v2/trigger.rb +64 -25
  47. data/lib/vagrant/shared_helpers.rb +28 -0
  48. data/lib/vagrant/ui.rb +51 -5
  49. data/lib/vagrant/util.rb +1 -0
  50. data/lib/vagrant/util/ansi_escape_code_remover.rb +1 -1
  51. data/lib/vagrant/util/caps.rb +48 -0
  52. data/lib/vagrant/util/credential_scrubber.rb +1 -1
  53. data/lib/vagrant/util/curl_helper.rb +8 -5
  54. data/lib/vagrant/util/directory.rb +19 -0
  55. data/lib/vagrant/util/downloader.rb +7 -3
  56. data/lib/vagrant/util/file_checksum.rb +6 -2
  57. data/lib/vagrant/util/guest_hosts.rb +68 -0
  58. data/lib/vagrant/util/guest_inspection.rb +9 -1
  59. data/lib/vagrant/util/install_cli_autocomplete.rb +118 -0
  60. data/lib/vagrant/util/io.rb +7 -27
  61. data/lib/vagrant/util/ipv4_interfaces.rb +15 -0
  62. data/lib/vagrant/util/is_port_open.rb +8 -20
  63. data/lib/vagrant/util/map_command_options.rb +33 -0
  64. data/lib/vagrant/util/network_ip.rb +11 -1
  65. data/lib/vagrant/util/numeric.rb +69 -0
  66. data/lib/vagrant/util/platform.rb +8 -1
  67. data/lib/vagrant/util/powershell.rb +1 -1
  68. data/lib/vagrant/util/subprocess.rb +9 -1
  69. data/lib/vagrant/vagrantfile.rb +1 -1
  70. data/plugins/commands/autocomplete/command/install.rb +49 -0
  71. data/plugins/commands/autocomplete/command/root.rb +64 -0
  72. data/plugins/commands/autocomplete/plugin.rb +18 -0
  73. data/plugins/commands/box/command/outdated.rb +14 -2
  74. data/plugins/commands/cloud/locales/en.yml +1 -1
  75. data/plugins/commands/cloud/publish.rb +1 -1
  76. data/plugins/commands/destroy/command.rb +6 -2
  77. data/plugins/commands/snapshot/command/save.rb +13 -8
  78. data/plugins/commands/ssh_config/command.rb +1 -1
  79. data/plugins/communicators/ssh/communicator.rb +25 -24
  80. data/plugins/communicators/winrm/config.rb +1 -1
  81. data/plugins/communicators/winrm/helper.rb +1 -1
  82. data/plugins/communicators/winrm/shell.rb +1 -1
  83. data/plugins/communicators/winssh/communicator.rb +126 -38
  84. data/plugins/communicators/winssh/config.rb +3 -7
  85. data/plugins/guests/alpine/cap/change_host_name.rb +10 -11
  86. data/plugins/guests/alpine/cap/rsync.rb +1 -1
  87. data/plugins/guests/alpine/plugin.rb +16 -0
  88. data/plugins/guests/alt/cap/change_host_name.rb +40 -53
  89. data/plugins/guests/arch/cap/change_host_name.rb +5 -14
  90. data/plugins/guests/arch/cap/configure_networks.rb +27 -10
  91. data/plugins/guests/atomic/cap/change_host_name.rb +5 -14
  92. data/plugins/guests/centos/cap/flavor.rb +24 -0
  93. data/plugins/guests/centos/guest.rb +9 -0
  94. data/plugins/guests/centos/plugin.rb +20 -0
  95. data/plugins/guests/darwin/cap/change_host_name.rb +10 -6
  96. data/plugins/guests/darwin/cap/mount_vmware_shared_folder.rb +99 -13
  97. data/plugins/guests/darwin/plugin.rb +5 -0
  98. data/plugins/guests/debian/cap/change_host_name.rb +11 -11
  99. data/plugins/guests/debian/cap/configure_networks.rb +14 -6
  100. data/plugins/guests/esxi/cap/public_key.rb +3 -1
  101. data/plugins/guests/freebsd/cap/change_host_name.rb +10 -6
  102. data/plugins/guests/gentoo/cap/change_host_name.rb +14 -22
  103. data/plugins/guests/haiku/cap/rsync.rb +19 -0
  104. data/plugins/guests/haiku/plugin.rb +15 -0
  105. data/plugins/guests/linux/cap/change_host_name.rb +46 -0
  106. data/plugins/guests/linux/cap/halt.rb +9 -1
  107. data/plugins/guests/linux/cap/mount_smb_shared_folder.rb +16 -0
  108. data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +4 -11
  109. data/plugins/guests/linux/cap/persist_mount_shared_folder.rb +62 -0
  110. data/plugins/guests/linux/cap/reboot.rb +48 -0
  111. data/plugins/guests/linux/plugin.rb +20 -0
  112. data/plugins/guests/omnios/cap/change_host_name.rb +10 -16
  113. data/plugins/guests/openbsd/cap/change_host_name.rb +10 -6
  114. data/plugins/guests/photon/cap/change_host_name.rb +9 -15
  115. data/plugins/guests/pld/cap/change_host_name.rb +11 -17
  116. data/plugins/guests/redhat/cap/change_host_name.rb +10 -5
  117. data/plugins/guests/redhat/cap/flavor.rb +3 -1
  118. data/plugins/guests/redhat/cap/nfs_client.rb +2 -2
  119. data/plugins/guests/redhat/cap/smb.rb +20 -0
  120. data/plugins/guests/redhat/plugin.rb +5 -0
  121. data/plugins/guests/slackware/cap/change_host_name.rb +11 -17
  122. data/plugins/guests/solaris11/plugin.rb +5 -0
  123. data/plugins/guests/suse/cap/change_host_name.rb +13 -12
  124. data/plugins/guests/windows/cap/public_key.rb +3 -3
  125. data/plugins/guests/windows/cap/reboot.rb +2 -1
  126. data/plugins/hosts/darwin/cap/fs_iso.rb +49 -0
  127. data/plugins/hosts/darwin/cap/nfs.rb +11 -0
  128. data/plugins/hosts/darwin/plugin.rb +15 -0
  129. data/plugins/hosts/linux/cap/fs_iso.rb +49 -0
  130. data/plugins/hosts/linux/cap/nfs.rb +21 -2
  131. data/plugins/hosts/linux/cap/rdp.rb +1 -1
  132. data/plugins/hosts/linux/plugin.rb +10 -0
  133. data/plugins/hosts/windows/cap/fs_iso.rb +48 -0
  134. data/plugins/hosts/windows/cap/rdp.rb +1 -1
  135. data/plugins/hosts/windows/plugin.rb +15 -0
  136. data/plugins/kernel_v2/config/cloud_init.rb +126 -0
  137. data/plugins/kernel_v2/config/disk.rb +221 -0
  138. data/plugins/kernel_v2/config/ssh_connect.rb +24 -0
  139. data/plugins/kernel_v2/config/vm.rb +225 -11
  140. data/plugins/kernel_v2/config/vm_provisioner.rb +17 -3
  141. data/plugins/kernel_v2/config/vm_trigger.rb +6 -5
  142. data/plugins/providers/docker/action.rb +8 -17
  143. data/plugins/providers/docker/action/forwarded_ports.rb +2 -0
  144. data/plugins/providers/docker/action/prepare_forwarded_port_collision_params.rb +61 -0
  145. data/plugins/providers/docker/cap/has_communicator.rb +11 -0
  146. data/plugins/providers/docker/communicator.rb +1 -1
  147. data/plugins/providers/docker/driver.rb +73 -10
  148. data/plugins/providers/docker/errors.rb +4 -0
  149. data/plugins/providers/docker/executor/local.rb +7 -1
  150. data/plugins/providers/docker/plugin.rb +5 -0
  151. data/plugins/providers/hyperv/action.rb +2 -0
  152. data/plugins/providers/hyperv/action/configure.rb +8 -0
  153. data/plugins/providers/hyperv/action/export.rb +4 -2
  154. data/plugins/providers/hyperv/cap/cleanup_disks.rb +54 -0
  155. data/plugins/providers/hyperv/cap/configure_disks.rb +200 -0
  156. data/plugins/providers/hyperv/cap/validate_disk_ext.rb +34 -0
  157. data/plugins/providers/hyperv/config.rb +5 -0
  158. data/plugins/providers/hyperv/driver.rb +90 -9
  159. data/plugins/providers/hyperv/plugin.rb +25 -0
  160. data/plugins/providers/hyperv/scripts/attach_disk_drive.ps1 +28 -0
  161. data/plugins/providers/hyperv/scripts/dismount_vhd.ps1 +13 -0
  162. data/plugins/providers/hyperv/scripts/get_vhd.ps1 +16 -0
  163. data/plugins/providers/hyperv/scripts/get_vm_status.ps1 +1 -1
  164. data/plugins/providers/hyperv/scripts/list_hdds.ps1 +17 -0
  165. data/plugins/providers/hyperv/scripts/new_vhd.ps1 +31 -0
  166. data/plugins/providers/hyperv/scripts/remove_disk_drive.ps1 +25 -0
  167. data/plugins/providers/hyperv/scripts/resize_disk_drive.ps1 +18 -0
  168. data/plugins/providers/hyperv/scripts/set_enhanced_session_transport_type.ps1 +24 -0
  169. data/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 +3 -3
  170. data/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 +14 -6
  171. data/plugins/providers/virtualbox/action.rb +14 -1
  172. data/plugins/providers/virtualbox/action/clean_machine_folder.rb +10 -1
  173. data/plugins/providers/virtualbox/action/export.rb +4 -2
  174. data/plugins/providers/virtualbox/action/forward_ports.rb +2 -2
  175. data/plugins/providers/virtualbox/action/import.rb +8 -4
  176. data/plugins/providers/virtualbox/action/prepare_clone_snapshot.rb +4 -2
  177. data/plugins/providers/virtualbox/action/snapshot_delete.rb +4 -2
  178. data/plugins/providers/virtualbox/action/snapshot_restore.rb +4 -2
  179. data/plugins/providers/virtualbox/cap/cleanup_disks.rb +85 -0
  180. data/plugins/providers/virtualbox/cap/configure_disks.rb +440 -0
  181. data/plugins/providers/virtualbox/cap/mount_options.rb +35 -0
  182. data/plugins/providers/virtualbox/cap/validate_disk_ext.rb +34 -0
  183. data/plugins/providers/virtualbox/driver/base.rb +15 -0
  184. data/plugins/providers/virtualbox/driver/meta.rb +17 -2
  185. data/plugins/providers/virtualbox/driver/version_5_0.rb +217 -2
  186. data/plugins/providers/virtualbox/driver/version_6_1.rb +39 -0
  187. data/plugins/providers/virtualbox/model/storage_controller.rb +135 -0
  188. data/plugins/providers/virtualbox/model/storage_controller_array.rb +100 -0
  189. data/plugins/providers/virtualbox/plugin.rb +38 -0
  190. data/plugins/providers/virtualbox/synced_folder.rb +1 -0
  191. data/plugins/provisioners/ansible/cap/guest/alpine/ansible_install.rb +44 -0
  192. data/plugins/provisioners/ansible/cap/guest/arch/ansible_install.rb +20 -3
  193. data/plugins/provisioners/ansible/cap/guest/debian/ansible_install.rb +4 -5
  194. data/plugins/provisioners/ansible/cap/guest/fedora/ansible_install.rb +2 -2
  195. data/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb +2 -2
  196. data/plugins/provisioners/ansible/cap/guest/pip/pip.rb +8 -4
  197. data/plugins/provisioners/ansible/cap/guest/redhat/ansible_install.rb +2 -2
  198. data/plugins/provisioners/ansible/cap/guest/suse/ansible_install.rb +2 -1
  199. data/plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install.rb +3 -3
  200. data/plugins/provisioners/ansible/plugin.rb +5 -0
  201. data/plugins/provisioners/ansible/provisioner/base.rb +1 -1
  202. data/plugins/provisioners/container/client.rb +203 -0
  203. data/plugins/provisioners/container/config.rb +83 -0
  204. data/plugins/provisioners/container/installer.rb +13 -0
  205. data/plugins/provisioners/container/plugin.rb +23 -0
  206. data/plugins/provisioners/container/provisioner.rb +28 -0
  207. data/plugins/provisioners/docker/cap/{redhat → centos}/docker_install.rb +10 -7
  208. data/plugins/provisioners/docker/cap/centos/docker_start_service.rb +24 -0
  209. data/plugins/provisioners/docker/client.rb +4 -175
  210. data/plugins/provisioners/docker/config.rb +2 -72
  211. data/plugins/provisioners/docker/installer.rb +3 -5
  212. data/plugins/provisioners/docker/plugin.rb +6 -6
  213. data/plugins/provisioners/docker/provisioner.rb +4 -10
  214. data/plugins/provisioners/podman/cap/centos/podman_install.rb +35 -0
  215. data/plugins/provisioners/podman/cap/linux/podman_installed.rb +13 -0
  216. data/plugins/provisioners/podman/cap/redhat/podman_install.rb +26 -0
  217. data/plugins/provisioners/podman/client.rb +12 -0
  218. data/plugins/provisioners/podman/config.rb +28 -0
  219. data/plugins/provisioners/podman/installer.rb +33 -0
  220. data/plugins/provisioners/podman/plugin.rb +38 -0
  221. data/plugins/provisioners/podman/provisioner.rb +52 -0
  222. data/plugins/provisioners/salt/provisioner.rb +4 -0
  223. data/plugins/provisioners/shell/config.rb +1 -6
  224. data/plugins/provisioners/shell/provisioner.rb +61 -26
  225. data/plugins/synced_folders/nfs/synced_folder.rb +3 -1
  226. data/plugins/synced_folders/smb/cap/default_fstab_modification.rb +11 -0
  227. data/plugins/synced_folders/smb/cap/mount_options.rb +36 -0
  228. data/plugins/synced_folders/smb/plugin.rb +10 -0
  229. data/plugins/synced_folders/smb/synced_folder.rb +2 -2
  230. data/plugins/synced_folders/unix_mount_helpers.rb +14 -0
  231. data/templates/commands/init/Vagrantfile.erb +1 -1
  232. data/templates/guests/arch/{network_dhcp.erb → default_network/network_dhcp.erb} +0 -0
  233. data/templates/guests/arch/{network_static.erb → default_network/network_static.erb} +0 -0
  234. data/templates/guests/arch/{network_static6.erb → default_network/network_static6.erb} +0 -0
  235. data/templates/guests/arch/systemd_networkd/network_dhcp.erb +6 -0
  236. data/templates/guests/arch/systemd_networkd/network_static.erb +9 -0
  237. data/templates/guests/arch/systemd_networkd/network_static6.erb +9 -0
  238. data/templates/guests/linux/etc_fstab.erb +6 -0
  239. data/templates/locales/en.yml +235 -6
  240. data/templates/locales/providers_docker.yml +6 -0
  241. data/templates/nfs/exports_darwin.erb +7 -0
  242. data/vagrant.gemspec +12 -12
  243. data/version.txt +1 -1
  244. metadata +3937 -3686
  245. data/lib/vagrant/action/builtin/after_trigger.rb +0 -31
  246. data/lib/vagrant/action/builtin/before_trigger.rb +0 -28
  247. data/plugins/provisioners/docker/cap/redhat/docker_start_service.rb +0 -16
@@ -1,9 +1,12 @@
1
1
  module VagrantPlugins
2
2
  module Kernel_V2
3
3
  class SSHConnectConfig < Vagrant.plugin("2", :config)
4
+ DEFAULT_SSH_CONNECT_TIMEOUT = 15
5
+
4
6
  attr_accessor :host
5
7
  attr_accessor :port
6
8
  attr_accessor :config
9
+ attr_accessor :connect_timeout
7
10
  attr_accessor :private_key_path
8
11
  attr_accessor :username
9
12
  attr_accessor :password
@@ -20,6 +23,7 @@ module VagrantPlugins
20
23
  @host = UNSET_VALUE
21
24
  @port = UNSET_VALUE
22
25
  @config = UNSET_VALUE
26
+ @connect_timeout = UNSET_VALUE
23
27
  @private_key_path = UNSET_VALUE
24
28
  @username = UNSET_VALUE
25
29
  @password = UNSET_VALUE
@@ -47,6 +51,7 @@ module VagrantPlugins
47
51
  @dsa_authentication = true if @dsa_authentication == UNSET_VALUE
48
52
  @extra_args = nil if @extra_args == UNSET_VALUE
49
53
  @config = nil if @config == UNSET_VALUE
54
+ @connect_timeout = DEFAULT_SSH_CONNECT_TIMEOUT if @connect_timeout == UNSET_VALUE
50
55
 
51
56
  if @private_key_path && !@private_key_path.is_a?(Array)
52
57
  @private_key_path = [@private_key_path]
@@ -76,6 +81,15 @@ module VagrantPlugins
76
81
  when :secure
77
82
  @verify_host_key = :always
78
83
  end
84
+
85
+ # Attempt to convert timeout to integer value
86
+ # If we can't convert the connect timeout into an integer or
87
+ # if the value is less than 1, set it to the default value
88
+ begin
89
+ @connect_timeout = @connect_timeout.to_i
90
+ rescue
91
+ # ignore
92
+ end
79
93
  end
80
94
 
81
95
  # NOTE: This is _not_ a valid config validation method, since it
@@ -110,6 +124,16 @@ module VagrantPlugins
110
124
  machine.env.ui.warn(I18n.t("vagrant.config.ssh.paranoid_deprecated"))
111
125
  end
112
126
 
127
+ if !@connect_timeout.is_a?(Integer)
128
+ errors << I18n.t(
129
+ "vagrant.config.ssh.connect_timeout_invalid_type",
130
+ given: @connect_timeout.class.name)
131
+ elsif @connect_timeout < 1
132
+ errors << I18n.t(
133
+ "vagrant.config.ssh.connect_timeout_invalid_value",
134
+ given: @connect_timeout.to_s)
135
+ end
136
+
113
137
  errors
114
138
  end
115
139
  end
@@ -8,9 +8,12 @@ require "vagrant/config/v2/util"
8
8
  require "vagrant/util/platform"
9
9
  require "vagrant/util/presence"
10
10
  require "vagrant/util/experimental"
11
+ require "vagrant/util/map_command_options"
11
12
 
12
13
  require File.expand_path("../vm_provisioner", __FILE__)
13
14
  require File.expand_path("../vm_subvm", __FILE__)
15
+ require File.expand_path("../disk", __FILE__)
16
+ require File.expand_path("../cloud_init", __FILE__)
14
17
 
15
18
  module VagrantPlugins
16
19
  module Kernel_V2
@@ -20,6 +23,8 @@ module VagrantPlugins
20
23
  DEFAULT_VM_NAME = :default
21
24
 
22
25
  attr_accessor :allowed_synced_folder_types
26
+ attr_accessor :allow_fstab_modification
27
+ attr_accessor :allow_hosts_modification
23
28
  attr_accessor :base_mac
24
29
  attr_accessor :base_address
25
30
  attr_accessor :boot_timeout
@@ -36,6 +41,7 @@ module VagrantPlugins
36
41
  attr_accessor :box_download_client_cert
37
42
  attr_accessor :box_download_insecure
38
43
  attr_accessor :box_download_location_trusted
44
+ attr_accessor :box_download_options
39
45
  attr_accessor :communicator
40
46
  attr_accessor :graceful_halt_timeout
41
47
  attr_accessor :guest
@@ -43,6 +49,9 @@ module VagrantPlugins
43
49
  attr_accessor :post_up_message
44
50
  attr_accessor :usable_port_range
45
51
  attr_reader :provisioners
52
+ attr_reader :disks
53
+ attr_reader :cloud_init_configs
54
+ attr_reader :box_extra_download_options
46
55
 
47
56
  # This is an experimental feature that isn't public yet.
48
57
  attr_accessor :clone
@@ -51,6 +60,7 @@ module VagrantPlugins
51
60
  @logger = Log4r::Logger.new("vagrant::config::vm")
52
61
 
53
62
  @allowed_synced_folder_types = UNSET_VALUE
63
+ @allow_fstab_modification = UNSET_VALUE
54
64
  @base_mac = UNSET_VALUE
55
65
  @base_address = UNSET_VALUE
56
66
  @boot_timeout = UNSET_VALUE
@@ -64,8 +74,11 @@ module VagrantPlugins
64
74
  @box_download_client_cert = UNSET_VALUE
65
75
  @box_download_insecure = UNSET_VALUE
66
76
  @box_download_location_trusted = UNSET_VALUE
77
+ @box_download_options = UNSET_VALUE
78
+ @box_extra_download_options = UNSET_VALUE
67
79
  @box_url = UNSET_VALUE
68
80
  @box_version = UNSET_VALUE
81
+ @allow_hosts_modification = UNSET_VALUE
69
82
  @clone = UNSET_VALUE
70
83
  @communicator = UNSET_VALUE
71
84
  @graceful_halt_timeout = UNSET_VALUE
@@ -73,6 +86,8 @@ module VagrantPlugins
73
86
  @hostname = UNSET_VALUE
74
87
  @post_up_message = UNSET_VALUE
75
88
  @provisioners = []
89
+ @disks = []
90
+ @cloud_init_configs = []
76
91
  @usable_port_range = UNSET_VALUE
77
92
 
78
93
  # Internal state
@@ -123,6 +138,50 @@ module VagrantPlugins
123
138
  end
124
139
  end
125
140
 
141
+ # Merge defined disks
142
+ other_disks = other.instance_variable_get(:@disks)
143
+ new_disks = []
144
+ @disks.each do |p|
145
+ other_p = other_disks.find { |o| p.id == o.id }
146
+ if other_p
147
+ # there is an override. take it.
148
+ other_p.config = p.config.merge(other_p.config)
149
+
150
+ # Remove duplicate disk config from other
151
+ p = other_p
152
+ other_disks.delete(other_p)
153
+ end
154
+
155
+ # there is an override, merge it into the
156
+ new_disks << p.dup
157
+ end
158
+ other_disks.each do |p|
159
+ new_disks << p.dup
160
+ end
161
+ result.instance_variable_set(:@disks, new_disks)
162
+
163
+ # Merge defined cloud_init_configs
164
+ other_cloud_init_configs = other.instance_variable_get(:@cloud_init_configs)
165
+ new_cloud_init_configs = []
166
+ @cloud_init_configs.each do |p|
167
+ other_p = other_cloud_init_configs.find { |o| p.id == o.id }
168
+ if other_p
169
+ # there is an override. take it.
170
+ other_p.config = p.config.merge(other_p.config)
171
+
172
+ # Remove duplicate disk config from other
173
+ p = other_p
174
+ other_cloud_init_configs.delete(other_p)
175
+ end
176
+
177
+ # there is an override, merge it into the
178
+ new_cloud_init_configs << p.dup
179
+ end
180
+ other_cloud_init_configs.each do |p|
181
+ new_cloud_init_configs << p.dup
182
+ end
183
+ result.instance_variable_set(:@cloud_init_configs, new_cloud_init_configs)
184
+
126
185
  # Merge the providers by prepending any configuration blocks we
127
186
  # have for providers onto the new configuration.
128
187
  other_providers = other.instance_variable_get(:@__providers)
@@ -341,7 +400,7 @@ module VagrantPlugins
341
400
 
342
401
  if Vagrant::Util::Experimental.feature_enabled?("dependency_provisioners")
343
402
  opts = {before: before, after: after}
344
- prov = VagrantConfigProvisioner.new(name, type.to_sym, opts)
403
+ prov = VagrantConfigProvisioner.new(name, type.to_sym, **opts)
345
404
  else
346
405
  prov = VagrantConfigProvisioner.new(name, type.to_sym)
347
406
  end
@@ -351,7 +410,9 @@ module VagrantPlugins
351
410
  prov.preserve_order = !!options.delete(:preserve_order) if \
352
411
  options.key?(:preserve_order)
353
412
  prov.run = options.delete(:run) if options.key?(:run)
354
- prov.add_config(options, &block)
413
+ prov.communicator_required = options.delete(:communicator_required) if options.key?(:communicator_required)
414
+
415
+ prov.add_config(**options, &block)
355
416
  nil
356
417
  end
357
418
 
@@ -384,6 +445,63 @@ module VagrantPlugins
384
445
  @__defined_vms[name].config_procs << [options[:config_version], block] if block
385
446
  end
386
447
 
448
+ # Stores disk config options from Vagrantfile
449
+ #
450
+ # @param [Symbol] type
451
+ # @param [Hash] options
452
+ # @param [Block] block
453
+ def disk(type, **options, &block)
454
+ disk_config = VagrantConfigDisk.new(type)
455
+
456
+ # Remove provider__option options before set_options, otherwise will
457
+ # show up as missing setting
458
+ # Extract provider hash options as well
459
+ provider_options = {}
460
+ options.delete_if do |p,o|
461
+ if o.is_a?(Hash) || p.to_s.include?("__")
462
+ provider_options[p] = o
463
+ true
464
+ end
465
+ end
466
+
467
+ disk_config.set_options(options)
468
+
469
+ # Add provider config
470
+ disk_config.add_provider_config(**provider_options, &block)
471
+
472
+ if !Vagrant::Util::Experimental.feature_enabled?("disks")
473
+ @logger.warn("Disk config defined, but experimental feature is not enabled. To use this feature, enable it with the experimental flag `disks`. Disk will not be added to internal config, and will be ignored.")
474
+ return
475
+ end
476
+
477
+ @disks << disk_config
478
+ end
479
+
480
+ # Stores config options for cloud_init
481
+ #
482
+ # @param [Symbol] type
483
+ # @param [Hash] options
484
+ # @param [Block] block
485
+ def cloud_init(type=nil, **options, &block)
486
+ type = type.to_sym if type
487
+
488
+ cloud_init_config = VagrantConfigCloudInit.new(type)
489
+
490
+ if block_given?
491
+ block.call(cloud_init_config, VagrantConfigCloudInit)
492
+ else
493
+ # config is hash
494
+ cloud_init_config.set_options(options)
495
+ end
496
+
497
+ if !Vagrant::Util::Experimental.feature_enabled?("cloud_init")
498
+ @logger.warn("cloud_init config defined, but experimental feature is not enabled. To use this feature, enable it with the experimental flag `cloud_init`. cloud_init config will not be added to internal config, and will be ignored.")
499
+ return
500
+ end
501
+
502
+ @cloud_init_configs << cloud_init_config
503
+ end
504
+
387
505
  #-------------------------------------------------------------------
388
506
  # Internal methods, don't call these.
389
507
  #-------------------------------------------------------------------
@@ -410,6 +528,9 @@ module VagrantPlugins
410
528
  @box_download_location_trusted = false if @box_download_location_trusted == UNSET_VALUE
411
529
  @box_url = nil if @box_url == UNSET_VALUE
412
530
  @box_version = nil if @box_version == UNSET_VALUE
531
+ @box_download_options = {} if @box_download_options == UNSET_VALUE
532
+ @box_extra_download_options = Vagrant::Util::MapCommandOptions.map_to_command_options(@box_download_options)
533
+ @allow_hosts_modification = true if @allow_hosts_modification == UNSET_VALUE
413
534
  @clone = nil if @clone == UNSET_VALUE
414
535
  @communicator = nil if @communicator == UNSET_VALUE
415
536
  @graceful_halt_timeout = 60 if @graceful_halt_timeout == UNSET_VALUE
@@ -537,16 +658,19 @@ module VagrantPlugins
537
658
  options[:type] = :nfs
538
659
  end
539
660
 
540
- # Ignore NFS on Windows
541
- if options[:type] == :nfs && Vagrant::Util::Platform.windows?
542
- options.delete(:type)
543
- end
544
-
545
661
  if options[:hostpath] == '.'
546
662
  current_dir_shared = true
547
663
  end
548
664
  end
549
665
 
666
+ @disks.each do |d|
667
+ d.finalize!
668
+ end
669
+
670
+ @cloud_init_configs.each do |c|
671
+ c.finalize!
672
+ end
673
+
550
674
  if !current_dir_shared && !@__synced_folders["/vagrant"]
551
675
  synced_folder(".", "/vagrant")
552
676
  end
@@ -601,6 +725,17 @@ module VagrantPlugins
601
725
  def validate(machine, ignore_provider=nil)
602
726
  errors = _detected_errors
603
727
 
728
+ if @allow_fstab_modification == UNSET_VALUE
729
+ machine.synced_folders.types.each do |impl_name|
730
+ inst = machine.synced_folders.type(impl_name)
731
+ if inst.capability?(:default_fstab_modification) && inst.capability(:default_fstab_modification) == false
732
+ @allow_fstab_modification = false
733
+ break
734
+ end
735
+ end
736
+ @allow_fstab_modification = true if @allow_fstab_modification == UNSET_VALUE
737
+ end
738
+
604
739
  if !box && !clone && !machine.provider_options[:box_optional]
605
740
  errors << I18n.t("vagrant.config.vm.box_missing")
606
741
  end
@@ -609,7 +744,11 @@ module VagrantPlugins
609
744
  errors << I18n.t("vagrant.config.vm.clone_and_box")
610
745
  end
611
746
 
612
- errors << I18n.t("vagrant.config.vm.hostname_invalid_characters") if \
747
+ if box && box.empty?
748
+ errors << I18n.t("vagrant.config.vm.box_empty", machine_name: machine.name)
749
+ end
750
+
751
+ errors << I18n.t("vagrant.config.vm.hostname_invalid_characters", name: machine.name) if \
613
752
  @hostname && @hostname !~ /^[a-z0-9][-.a-z0-9]*$/i
614
753
 
615
754
  if @box_version
@@ -653,6 +792,19 @@ module VagrantPlugins
653
792
  end
654
793
  end
655
794
 
795
+ if !box_download_options.is_a?(Hash)
796
+ errors << I18n.t("vagrant.config.vm.box_download_options_type", type: box_download_options.class.to_s)
797
+ end
798
+
799
+ box_download_options.each do |k, v|
800
+ # If the value is truthy and
801
+ # if `box_extra_download_options` does not include the key
802
+ # then the conversion to extra download options produced an error
803
+ if v && !box_extra_download_options.include?("--#{k}")
804
+ errors << I18n.t("vagrant.config.vm.box_download_options_not_converted", missing_key: k)
805
+ end
806
+ end
807
+
656
808
  used_guest_paths = Set.new
657
809
  @__synced_folders.each do |id, options|
658
810
  # If the shared folder is disabled then don't worry about validating it
@@ -694,9 +846,14 @@ module VagrantPlugins
694
846
  errors << I18n.t("vagrant.config.vm.shared_folder_mount_options_array")
695
847
  end
696
848
 
697
- # One day remove this probably.
698
- if options[:extra]
699
- errors << "The 'extra' flag on synced folders is now 'mount_options'"
849
+ if options[:type]
850
+ plugins = Vagrant.plugin("2").manager.synced_folders
851
+ impl_class = plugins[options[:type]]
852
+ if !impl_class
853
+ errors << I18n.t("vagrant.config.vm.shared_folder_invalid_option_type",
854
+ type: options[:type],
855
+ options: plugins.keys.join(', '))
856
+ end
700
857
  end
701
858
  end
702
859
 
@@ -706,7 +863,17 @@ module VagrantPlugins
706
863
  valid_network_types = [:forwarded_port, :private_network, :public_network]
707
864
 
708
865
  port_range=(1..65535)
866
+ has_hostname_config = false
709
867
  networks.each do |type, options|
868
+ if options[:hostname]
869
+ if has_hostname_config
870
+ errors << I18n.t("vagrant.config.vm.multiple_networks_set_hostname")
871
+ end
872
+ if options[:ip] == nil
873
+ errors << I18n.t("vagrant.config.vm.network_with_hostname_must_set_ip")
874
+ end
875
+ has_hostname_config = true
876
+ end
710
877
  if !valid_network_types.include?(type)
711
878
  errors << I18n.t("vagrant.config.vm.network_type_invalid",
712
879
  type: type.to_s)
@@ -748,6 +915,41 @@ module VagrantPlugins
748
915
  end
749
916
  end
750
917
 
918
+ # Validate disks
919
+ # Check if there is more than one primary disk defined and throw an error
920
+ primary_disks = @disks.select { |d| d.primary && d.type == :disk }
921
+ if primary_disks.size > 1
922
+ errors << I18n.t("vagrant.config.vm.multiple_primary_disks_error",
923
+ name: machine.name)
924
+ end
925
+
926
+ disk_names = @disks.map { |d| d.name }
927
+ duplicate_names = disk_names.find_all { |d| disk_names.count(d) > 1 }
928
+ if duplicate_names.any?
929
+ errors << I18n.t("vagrant.config.vm.multiple_disk_names_error",
930
+ name: machine.name,
931
+ disk_names: duplicate_names.uniq.join("\n"))
932
+ end
933
+
934
+ disk_files = @disks.map { |d| d.file }
935
+ duplicate_files = disk_files.find_all { |d| d && disk_files.count(d) > 1 }
936
+ if duplicate_files.any?
937
+ errors << I18n.t("vagrant.config.vm.multiple_disk_files_error",
938
+ name: machine.name,
939
+ disk_files: duplicate_files.uniq.join("\n"))
940
+ end
941
+
942
+ @disks.each do |d|
943
+ error = d.validate(machine)
944
+ errors.concat(error) if !error.empty?
945
+ end
946
+
947
+ # Validate clout_init_configs
948
+ @cloud_init_configs.each do |c|
949
+ error = c.validate(machine)
950
+ errors.concat error if !error.empty?
951
+ end
952
+
751
953
  # We're done with VM level errors so prepare the section
752
954
  errors = { "vm" => errors }
753
955
 
@@ -822,6 +1024,18 @@ module VagrantPlugins
822
1024
  end
823
1025
  end
824
1026
 
1027
+ if ![TrueClass, FalseClass].include?(@allow_fstab_modification.class)
1028
+ errors["vm"] << I18n.t("vagrant.config.vm.config_type",
1029
+ option: "allow_fstab_modification", given: @allow_fstab_modification.class, required: "Boolean"
1030
+ )
1031
+ end
1032
+
1033
+ if ![TrueClass, FalseClass].include?(@allow_hosts_modification.class)
1034
+ errors["vm"] << I18n.t("vagrant.config.vm.config_type",
1035
+ option: "allow_hosts_modification", given: @allow_hosts_modification.class, required: "Boolean"
1036
+ )
1037
+ end
1038
+
825
1039
  errors
826
1040
  end
827
1041
 
@@ -9,7 +9,10 @@ module VagrantPlugins
9
9
 
10
10
  # Unique name for this provisioner
11
11
  #
12
- # @return [String]
12
+ # Accepts a string, but is ultimately forced into a symbol in the top level method inside
13
+ # #Config::VM.provision method while being parsed from a Vagrantfile
14
+ #
15
+ # @return [Symbol]
13
16
  attr_reader :name
14
17
 
15
18
  # Internal unique name for this provisioner
@@ -53,6 +56,12 @@ module VagrantPlugins
53
56
  # @return [String, Symbol]
54
57
  attr_accessor :after
55
58
 
59
+ # Boolean, when true signifies that some communicator must
60
+ # be available in order for the provisioner to run.
61
+ #
62
+ # @return [Boolean]
63
+ attr_accessor :communicator_required
64
+
56
65
  def initialize(name, type, **options)
57
66
  @logger = Log4r::Logger.new("vagrant::config::vm::provisioner")
58
67
  @logger.debug("Provisioner defined: #{name}")
@@ -66,6 +75,7 @@ module VagrantPlugins
66
75
  @type = type
67
76
  @before = options[:before]
68
77
  @after = options[:after]
78
+ @communicator_required = options.fetch(:communicator_required, true)
69
79
 
70
80
  # Attempt to find the provisioner...
71
81
  if !Vagrant.plugin("2").manager.provisioners[type]
@@ -115,6 +125,10 @@ module VagrantPlugins
115
125
 
116
126
  provisioner_names = provisioners.map { |i| i.name.to_s if i.name != name }.compact
117
127
 
128
+ if ![TrueClass, FalseClass].include?(@communicator_required.class)
129
+ errors << I18n.t("vagrant.provisioners.base.wrong_type", opt: "communicator_required", type: "boolean")
130
+ end
131
+
118
132
  if @before && @after
119
133
  errors << I18n.t("vagrant.provisioners.base.both_before_after_set")
120
134
  end
@@ -124,7 +138,7 @@ module VagrantPlugins
124
138
  if @before.is_a?(Symbol) && !VALID_BEFORE_AFTER_TYPES.include?(@before)
125
139
  errors << I18n.t("vagrant.provisioners.base.invalid_alias_value", opt: "before", alias: VALID_BEFORE_AFTER_TYPES.join(", "))
126
140
  elsif !@before.is_a?(String) && !VALID_BEFORE_AFTER_TYPES.include?(@before)
127
- errors << I18n.t("vagrant.provisioners.base.wrong_type", opt: "before")
141
+ errors << I18n.t("vagrant.provisioners.base.wrong_type", opt: "before", type: "string")
128
142
  end
129
143
 
130
144
  if !provisioner_names.include?(@before)
@@ -150,7 +164,7 @@ module VagrantPlugins
150
164
  if @after.is_a?(Symbol)
151
165
  errors << I18n.t("vagrant.provisioners.base.invalid_alias_value", opt: "after", alias: VALID_BEFORE_AFTER_TYPES.join(", "))
152
166
  elsif !@after.is_a?(String)
153
- errors << I18n.t("vagrant.provisioners.base.wrong_type", opt: "after")
167
+ errors << I18n.t("vagrant.provisioners.base.wrong_type", opt: "after", type: "string")
154
168
  end
155
169
 
156
170
  if !provisioner_names.include?(@after)