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.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/.hashibot.hcl +14 -0
  3. data/CHANGELOG.md +93 -2
  4. data/README.md +1 -3
  5. data/bin/vagrant +23 -0
  6. data/contrib/bash/completion.sh +13 -1
  7. data/lib/vagrant.rb +25 -0
  8. data/lib/vagrant/action.rb +5 -0
  9. data/lib/vagrant/action/builder.rb +145 -24
  10. data/lib/vagrant/action/builtin/box_add.rb +11 -4
  11. data/lib/vagrant/action/builtin/box_check_outdated.rb +12 -15
  12. data/lib/vagrant/action/builtin/cleanup_disks.rb +56 -0
  13. data/lib/vagrant/action/builtin/delayed.rb +26 -0
  14. data/lib/vagrant/action/builtin/disk.rb +52 -0
  15. data/lib/vagrant/action/builtin/handle_box.rb +2 -0
  16. data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +28 -9
  17. data/lib/vagrant/action/builtin/mixin_provisioners.rb +19 -1
  18. data/lib/vagrant/action/builtin/ssh_run.rb +21 -3
  19. data/lib/vagrant/action/builtin/trigger.rb +36 -0
  20. data/lib/vagrant/action/hook.rb +20 -2
  21. data/lib/vagrant/action/runner.rb +11 -26
  22. data/lib/vagrant/action/warden.rb +4 -18
  23. data/lib/vagrant/box_metadata.rb +17 -3
  24. data/lib/vagrant/bundler.rb +260 -53
  25. data/lib/vagrant/cli.rb +4 -2
  26. data/lib/vagrant/errors.rb +24 -0
  27. data/lib/vagrant/machine.rb +9 -6
  28. data/lib/vagrant/plugin/manager.rb +25 -14
  29. data/lib/vagrant/plugin/v2/command.rb +1 -1
  30. data/lib/vagrant/plugin/v2/manager.rb +53 -0
  31. data/lib/vagrant/plugin/v2/plugin.rb +1 -0
  32. data/lib/vagrant/plugin/v2/trigger.rb +64 -26
  33. data/lib/vagrant/shared_helpers.rb +28 -0
  34. data/lib/vagrant/ui.rb +50 -4
  35. data/lib/vagrant/util.rb +1 -0
  36. data/lib/vagrant/util/curl_helper.rb +8 -5
  37. data/lib/vagrant/util/downloader.rb +5 -1
  38. data/lib/vagrant/util/file_checksum.rb +6 -2
  39. data/lib/vagrant/util/guest_inspection.rb +9 -1
  40. data/lib/vagrant/util/io.rb +7 -27
  41. data/lib/vagrant/util/is_port_open.rb +1 -2
  42. data/lib/vagrant/util/map_command_options.rb +33 -0
  43. data/lib/vagrant/util/numeric.rb +69 -0
  44. data/lib/vagrant/util/platform.rb +8 -1
  45. data/plugins/commands/box/command/outdated.rb +14 -2
  46. data/plugins/commands/cloud/locales/en.yml +1 -1
  47. data/plugins/commands/cloud/publish.rb +1 -1
  48. data/plugins/commands/snapshot/command/save.rb +13 -8
  49. data/plugins/commands/ssh_config/command.rb +1 -1
  50. data/plugins/communicators/ssh/communicator.rb +18 -23
  51. data/plugins/communicators/winrm/config.rb +1 -1
  52. data/plugins/communicators/winrm/shell.rb +1 -1
  53. data/plugins/communicators/winssh/communicator.rb +126 -38
  54. data/plugins/communicators/winssh/config.rb +3 -7
  55. data/plugins/guests/alpine/cap/rsync.rb +1 -1
  56. data/plugins/guests/alpine/plugin.rb +16 -0
  57. data/plugins/guests/centos/cap/flavor.rb +24 -0
  58. data/plugins/guests/centos/guest.rb +9 -0
  59. data/plugins/guests/centos/plugin.rb +20 -0
  60. data/plugins/guests/darwin/cap/mount_vmware_shared_folder.rb +99 -13
  61. data/plugins/guests/darwin/plugin.rb +5 -0
  62. data/plugins/guests/debian/cap/configure_networks.rb +14 -6
  63. data/plugins/guests/linux/cap/halt.rb +9 -1
  64. data/plugins/guests/linux/cap/mount_smb_shared_folder.rb +16 -0
  65. data/plugins/guests/linux/cap/reboot.rb +48 -0
  66. data/plugins/guests/linux/plugin.rb +10 -0
  67. data/plugins/guests/redhat/cap/flavor.rb +3 -1
  68. data/plugins/guests/redhat/cap/nfs_client.rb +2 -2
  69. data/plugins/guests/redhat/cap/smb.rb +20 -0
  70. data/plugins/guests/redhat/plugin.rb +5 -0
  71. data/plugins/guests/suse/cap/change_host_name.rb +2 -2
  72. data/plugins/guests/windows/cap/public_key.rb +3 -3
  73. data/plugins/guests/windows/cap/reboot.rb +2 -1
  74. data/plugins/hosts/darwin/cap/nfs.rb +11 -0
  75. data/plugins/hosts/darwin/plugin.rb +5 -0
  76. data/plugins/hosts/linux/cap/nfs.rb +21 -2
  77. data/plugins/kernel_v2/config/disk.rb +199 -0
  78. data/plugins/kernel_v2/config/ssh_connect.rb +24 -0
  79. data/plugins/kernel_v2/config/vm.rb +109 -4
  80. data/plugins/kernel_v2/config/vm_provisioner.rb +4 -1
  81. data/plugins/kernel_v2/config/vm_trigger.rb +2 -5
  82. data/plugins/providers/docker/driver.rb +38 -10
  83. data/plugins/providers/docker/errors.rb +4 -0
  84. data/plugins/providers/docker/executor/local.rb +7 -1
  85. data/plugins/providers/hyperv/action/export.rb +4 -2
  86. data/plugins/providers/hyperv/driver.rb +10 -9
  87. data/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 +3 -3
  88. data/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 +6 -6
  89. data/plugins/providers/virtualbox/action.rb +2 -0
  90. data/plugins/providers/virtualbox/action/clean_machine_folder.rb +10 -1
  91. data/plugins/providers/virtualbox/action/export.rb +4 -2
  92. data/plugins/providers/virtualbox/action/import.rb +8 -4
  93. data/plugins/providers/virtualbox/action/prepare_clone_snapshot.rb +4 -2
  94. data/plugins/providers/virtualbox/action/snapshot_delete.rb +4 -2
  95. data/plugins/providers/virtualbox/action/snapshot_restore.rb +4 -2
  96. data/plugins/providers/virtualbox/cap/cleanup_disks.rb +54 -0
  97. data/plugins/providers/virtualbox/cap/configure_disks.rb +287 -0
  98. data/plugins/providers/virtualbox/cap/validate_disk_ext.rb +27 -0
  99. data/plugins/providers/virtualbox/driver/base.rb +15 -0
  100. data/plugins/providers/virtualbox/driver/meta.rb +14 -2
  101. data/plugins/providers/virtualbox/driver/version_5_0.rb +142 -2
  102. data/plugins/providers/virtualbox/driver/version_6_1.rb +39 -0
  103. data/plugins/providers/virtualbox/plugin.rb +21 -0
  104. data/plugins/provisioners/ansible/cap/guest/alpine/ansible_install.rb +44 -0
  105. data/plugins/provisioners/ansible/cap/guest/arch/ansible_install.rb +20 -3
  106. data/plugins/provisioners/ansible/cap/guest/debian/ansible_install.rb +4 -5
  107. data/plugins/provisioners/ansible/cap/guest/fedora/ansible_install.rb +2 -2
  108. data/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb +2 -2
  109. data/plugins/provisioners/ansible/cap/guest/pip/pip.rb +8 -4
  110. data/plugins/provisioners/ansible/cap/guest/redhat/ansible_install.rb +2 -2
  111. data/plugins/provisioners/ansible/cap/guest/suse/ansible_install.rb +2 -1
  112. data/plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install.rb +3 -3
  113. data/plugins/provisioners/ansible/plugin.rb +5 -0
  114. data/plugins/provisioners/ansible/provisioner/base.rb +1 -1
  115. data/plugins/provisioners/container/client.rb +203 -0
  116. data/plugins/provisioners/container/config.rb +83 -0
  117. data/plugins/provisioners/container/installer.rb +13 -0
  118. data/plugins/provisioners/container/plugin.rb +23 -0
  119. data/plugins/provisioners/container/provisioner.rb +28 -0
  120. data/plugins/provisioners/docker/cap/{redhat → centos}/docker_install.rb +10 -7
  121. data/plugins/provisioners/docker/cap/centos/docker_start_service.rb +24 -0
  122. data/plugins/provisioners/docker/client.rb +4 -175
  123. data/plugins/provisioners/docker/config.rb +2 -72
  124. data/plugins/provisioners/docker/installer.rb +3 -5
  125. data/plugins/provisioners/docker/plugin.rb +6 -6
  126. data/plugins/provisioners/docker/provisioner.rb +4 -10
  127. data/plugins/provisioners/podman/cap/centos/podman_install.rb +35 -0
  128. data/plugins/provisioners/podman/cap/linux/podman_installed.rb +13 -0
  129. data/plugins/provisioners/podman/cap/redhat/podman_install.rb +26 -0
  130. data/plugins/provisioners/podman/client.rb +12 -0
  131. data/plugins/provisioners/podman/config.rb +28 -0
  132. data/plugins/provisioners/podman/installer.rb +33 -0
  133. data/plugins/provisioners/podman/plugin.rb +38 -0
  134. data/plugins/provisioners/podman/provisioner.rb +52 -0
  135. data/plugins/provisioners/salt/provisioner.rb +4 -0
  136. data/plugins/provisioners/shell/config.rb +1 -6
  137. data/plugins/provisioners/shell/provisioner.rb +54 -25
  138. data/plugins/synced_folders/smb/synced_folder.rb +1 -1
  139. data/templates/commands/init/Vagrantfile.erb +1 -1
  140. data/templates/locales/en.yml +123 -4
  141. data/templates/locales/providers_docker.yml +2 -0
  142. data/templates/nfs/exports_darwin.erb +7 -0
  143. data/vagrant.gemspec +8 -9
  144. data/version.txt +1 -1
  145. metadata +3731 -3663
  146. data/lib/vagrant/action/builtin/after_trigger.rb +0 -31
  147. data/lib/vagrant/action/builtin/before_trigger.rb +0 -28
  148. data/plugins/provisioners/docker/cap/redhat/docker_start_service.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f5ee7bf52fe56d658a0fcf504b6c249cfe7b44ac95ecceca6bae522ddff8059
4
- data.tar.gz: ebe57eb1296b2aabb5743cdf206542b51a77b49a0da762cb543b65b086ddce38
3
+ metadata.gz: fc8998228365e044e5c4dae334de559593ead91cec2b40a2fb4b659068de08ed
4
+ data.tar.gz: a1c1681b1fcea9ad3079a71ce3a36ff13a950149d997ccb110c95bec92c7a329
5
5
  SHA512:
6
- metadata.gz: e1ef1d56b65999992a07f14ffc27badda9932de46b307512ee94bb54736c9931699391d48a992ce083d3dff4f517338c8f2e9bd5d3257c7c937bcfc9a0e93309
7
- data.tar.gz: b9767d4e3f0d6a5e09f9028642eb10237eca09f155d9a1dad7b29e6d18ef8db88aa80776f9992e6226dca4ccc2dbc60e91d8fd17a32a99fca981710eb4698f73
6
+ metadata.gz: 46388919cbbee6ce29ad5a4590ca652736076d1f951d50574ff66babd15acb22829db1e61a4bae7962af5734d27e7fbbc6c8262fc62ac147ac5d0736e560051b
7
+ data.tar.gz: 6ceff4e11163fe20e30415a9582c34a94b8241603c0807cc9a8cd10209fc9904ce7cd79f6ae66a2e238d179d90aef071b894792e649d8223f327b511d2c735f3
@@ -0,0 +1,14 @@
1
+ poll "closed_issue_locker" "locker" {
2
+ schedule = "0 50 1 * * *"
3
+ closed_for = "720h" # 30 days
4
+ max_issues = 500
5
+ sleep_between_issues = "5s"
6
+
7
+ no_comment_if_no_activity_for = "4320h" # 180 days
8
+
9
+ message = <<-EOF
10
+ I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
11
+
12
+ If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
13
+ EOF
14
+ }
@@ -1,3 +1,94 @@
1
+ ## 2.2.9 (May 07, 2020)
2
+
3
+ BUG FIXES:
4
+
5
+ - core/bundler: Properly handle plugin install with available specification [GH-11592]
6
+ - provisioners/docker: Fix CentOS docker install and start service capabilities [GH-11581]
7
+ - provisioners/podman: Seperate RHEL install from CentOS install [GH-11584]
8
+
9
+ ## 2.2.8 (May 04, 2020)
10
+
11
+ FEATURES:
12
+
13
+ - virtualbox/disks: Add ability to manage virtual disks for guests [GH-11349]
14
+
15
+ IMPROVEMENTS:
16
+
17
+ - bin/vagrant: Automatically include global options within commands [GH-11473]
18
+ - bin/vagrant: Suppress Ruby warnings when not running pre-release version [GH-11446]
19
+ - communicator/ssh: Add support for configuring SSH connect timeout [GH-11533]
20
+ - core: Update childprocess gem [GH-11487]
21
+ - core: Add cli option `--no-tty` [GH-11414]
22
+ - core: Overhaul call stack modifications implementation for hooks and triggers [GH-11455]
23
+ - core/bundler: Cache plugin solution sets to speed up startup times [GH-11363]
24
+ - config/vm: Add`box_download_options` config to specify extra download options for a box [GH-11560]
25
+ - guest/alpine: Add ansible provisioner guest support [GH-11411]
26
+ - guest/linux: Update systemd? check to use sudo [GH-11398]
27
+ - guest/linux: Use systemd if available to halt and reboot system [GH-11407]
28
+ - guests/linux: Mount smb folders with `mfsymlinks` option by default [GH-11503]
29
+ - guest/redhat: Add support for SMB [GH-11463]
30
+ - guest/windows: Rescue all regular exceptions during reboot wait [GH-11428]
31
+ - providers/docker: Support catching container name when using podman [GH-11356]
32
+ - provisioners/docker: Support Centos8 [GH-11462]
33
+ - provisioners/podman: Add Podman as a provisioner [GH-11472]
34
+ - provisioners/salt: Allow specifying python_version [GH-11436]
35
+
36
+ BUG FIXES:
37
+
38
+ - communicators/winssh: Fix issues with Windows SSH communicator [GH-11430]
39
+ - core/bundler: Activate vagrant specification when not active [GH-11445]
40
+ - core/bundler: Properly resolve sets when Vagrant is in prerelease [GH-11571]
41
+ - core/downloader: Always set `-q` flag as first option [GH-11366]
42
+ - core/hooks: Update dynamic action hook implementation to prevent looping [GH-11427]
43
+ - core/synced_folders: Validate type option if set [GH-11359]
44
+ - guests/debian: Choose netplan renderer based on network configuration and installed tools [GH-11498]
45
+ - host/darwin: Quote directories in /etc/exports [GH-11441]
46
+ - host/linux: Ensure `/etc/exports` does not contain duplicate records [GH-10591]
47
+ - host/windows: Check all interfaces for port conflict when host_ip: "0.0.0.0" [GH-11454]
48
+ - providers/docker: Fix issue where Vagrant fails to remove image if it is in use [GH-11355]
49
+ - providers/docker: Fix issue with getting correct docker image id from build output [GH-11461]
50
+ - providers/hyperv: Prevent error when identity reference cannot be translated [GH-11425]
51
+ - provider/hyperv: Use service id for manipulating vm integration services [GH-11499]
52
+ - providers/virtualbox: Parse `list dhcpservers` output on VirtualBox 6.1 [GH-11404]
53
+ - providers/virtualbox: Raise an error if guest IP ends in .1 [GH-11500]
54
+ - provisioners/shell: Ensure windows shell provisioners always get an extension [GH-11517]
55
+ - util/io: Fix encoding conversion errors [GH-11571]
56
+
57
+ ## 2.2.7 (January 27, 2020)
58
+
59
+ IMPROVEMENTS:
60
+
61
+ - guest/opensuse: Check for basename hostname prior to setting hostname [GH-11170]
62
+ - host/linux: Check for modinfo in /sbin if it's not on PATH [GH-11178]
63
+ - core: Show guest name in hostname error message [GH-11175]
64
+ - provisioners/shell: Linux guests now support `reboot` option [GH-11194]
65
+ - darwin/nfs: Put each NFS export on its own line [GH-11216]
66
+ - contrib/bash: Add more completion flags to up command [GH-11223]
67
+ - provider/virtualbox: Add VirtualBox provider support for version 6.1.x [GH-11250]
68
+ - box/outdated: Allow to force check for box updates and ignore cached check [GH-11231]
69
+ - guest/alpine: Update apk cache when installing rsync [GH-11220]
70
+ - provider/virtualbox: Improve error message when machine folder is inaccessible [GH-11239]
71
+ - provisioner/ansible_local: Add pip install method for arch guests [GH-11265]
72
+ - communicators/winssh: Use Windows shell for `vagrant ssh -c` [GH-11258]
73
+
74
+ BUG FIXES:
75
+
76
+ - command/snapshot/save: Fix regression that prevented snapshot of all guests in environment [GH-11152]
77
+ - core: Update UI to properly retain newlines when adding prefix [GH-11126]
78
+ - core: Check if box update is available locally [GH-11188]
79
+ - core: Ensure Vagrant::Errors are loaded in file_checksum util [GH-11183]
80
+ - cloud/publish: Improve argument handling for missing arguments to command [GH-11184]
81
+ - core: Get latest version for current provider during outdated check [GH-11192]
82
+ - linux/nfs: avoid adding extra newlines to /etc/exports [GH-11201]
83
+ - guest/darwin: Fix VMware synced folders on APFS [GH-11267]
84
+ - guest/redhat: Ensure `nfs-server` is restarted when installing nfs client [GH-11212]
85
+ - core: Do not validate checksums if options are empty string [GH-11211]
86
+ - provider/docker: Enhance docker build method to match against buildkit output [GH-11205]
87
+ - provisioner/ansible_local: Don't prompt for input when installing Ansible on Ubuntu and Debian [GH-11191]
88
+ - provisioner/ansible_local: Ensure all guest caps accept all passed in arguments [GH-11265]
89
+ - host/windows: Fix regression that prevented port collisions from being detected [GH-11244]
90
+ - core/provisioner: Set top level provisioner name if set in a provisioner config [GH-11295]
91
+
1
92
  ## 2.2.6 (October 14, 2019)
2
93
 
3
94
  FEATURES:
@@ -13,7 +104,7 @@ IMPROVEMENTS:
13
104
  - guest/alt: Improve handling for using network tools when setting hostname [GH-11000]
14
105
  - guest/suse: Add ipv6 network config templates for SUSE based distributions [GH-11013]
15
106
  - guest/windows: Retry on connection timeout errors for the reboot capability [GH-11093]
16
- - host/bsd: Use host resolve path capability to modify local paths if requird [GH-11108]
107
+ - host/bsd: Use host resolve path capability to modify local paths if required [GH-11108]
17
108
  - host/darwin: Add host resolve path capability to provide real paths for firmlinks [GH-11108]
18
109
  - provisioners/chef: Update pkg install flags for chef on FreeBSD guests [GH-11075]
19
110
  - provider/hyperv: Improve error message when VMMS is not running [GH-10978]
@@ -509,7 +600,7 @@ BUG FIXES:
509
600
  - core: Rescue more exceptions when checking if port is open [GH-8517]
510
601
  - guests/solaris11: Inherit from Solaris guest and keep solaris11 specific methods [GH-9034]
511
602
  - guests/windows: Split out cygwin path helper for msys2/cygwin paths and ensure cygpath exists [GH-8972]
512
- - guests/windows: Specify expected shell when executing on guest (fixes winssh communicator usage) [GH-9012]
603
+ - guests/windows: Specify expected shell when executing on guest (fixes einssh communicator usage) [GH-9012]
513
604
  - guests/windows: Include WinSSH Communicator when using insert_public_key [GH-9105]
514
605
  - hosts/windows: Check for vagrant.exe when validating versions within WSL [GH-9107, GH-8962]
515
606
  - providers/docker: Isolate windows check within executor to handle running through VM [GH-8921]
data/README.md CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  * Website: [https://www.vagrantup.com/](https://www.vagrantup.com/)
4
4
  * Source: [https://github.com/hashicorp/vagrant](https://github.com/hashicorp/vagrant)
5
- * [![Gitter chat](https://badges.gitter.im/mitchellh/vagrant.png)](https://gitter.im/mitchellh/vagrant)
6
- * Mailing list: [Google Groups](https://groups.google.com/group/vagrant-up)
7
- * IRC: #vagrant on freenode.org
5
+ * HashiCorp Discuss: [https://discuss.hashicorp.com/c/vagrant/24](https://discuss.hashicorp.com/c/vagrant/24)
8
6
 
9
7
  Vagrant is a tool for building and distributing development environments.
10
8
 
@@ -94,6 +94,23 @@ begin
94
94
  # Schedule the cleanup of things
95
95
  at_exit(&Vagrant::Bundler.instance.method(:deinit))
96
96
 
97
+ # If this is not a pre-release disable verbose output
98
+ if !Vagrant.prerelease?
99
+ $VERBOSE = nil
100
+ end
101
+
102
+ # Add any option flags defined within this file here
103
+ # so they are automatically propagated to all commands
104
+ Vagrant.add_default_cli_options(proc { |o|
105
+ o.on("--[no-]color", "Enable or disable color output")
106
+ o.on("--machine-readable", "Enable machine readable output")
107
+ o.on("-v", "--version", "Display Vagrant version")
108
+ o.on("--debug", "Enable debug output")
109
+ o.on("--timestamp", "Enable timestamps on log output")
110
+ o.on("--debug-timestamp", "Enable debug output with timestamps")
111
+ o.on("--no-tty", "Enable non-interactive output")
112
+ })
113
+
97
114
  # Create a logger right away
98
115
  logger = Log4r::Logger.new("vagrant::bin::vagrant")
99
116
  logger.info("`vagrant` invoked: #{ARGV.inspect}")
@@ -130,6 +147,12 @@ begin
130
147
  opts[:ui_class] = Vagrant::UI::MachineReadable
131
148
  end
132
149
 
150
+ # Setting to enable/disable showing progress bars
151
+ if argv.include?("--no-tty")
152
+ argv.delete("--no-tty")
153
+ opts[:ui_class] = Vagrant::UI::NonInteractive
154
+ end
155
+
133
156
  # Default to colored output
134
157
  opts[:ui_class] ||= Vagrant::UI::Colored
135
158
 
@@ -75,7 +75,19 @@ _vagrant() {
75
75
  then
76
76
  local vm_list=$(find "${vagrant_state_file}/machines" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
77
77
  fi
78
- local up_commands="--no-provision"
78
+ local up_commands="\
79
+ --provision \
80
+ --no-provision \
81
+ --provision-with \
82
+ --destroy-on-error \
83
+ --no-destroy-on-error \
84
+ --parallel \
85
+ --no-parallel
86
+ --provider \
87
+ --install-provider \
88
+ --no-install-provider \
89
+ -h \
90
+ --help"
79
91
  COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur}))
80
92
  return 0
81
93
  ;;
@@ -9,6 +9,31 @@ class Log4r::BasicFormatter
9
9
  end
10
10
  end
11
11
 
12
+
13
+ require "optparse"
14
+
15
+ module Vagrant
16
+ # This is a customized OptionParser for Vagrant plugins. It
17
+ # will automatically add any default CLI options defined
18
+ # outside of command implementations to the local option
19
+ # parser instances in use
20
+ class OptionParser < ::OptionParser
21
+ def initialize(*_)
22
+ super
23
+ Vagrant.default_cli_options.each do |opt_proc|
24
+ opt_proc.call(self)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ # Inject the option parser into the vagrant plugins
31
+ # module so it is automatically used when defining
32
+ # command options
33
+ module VagrantPlugins
34
+ OptionParser = Vagrant::OptionParser
35
+ end
36
+
12
37
  require "vagrant/shared_helpers"
13
38
  require "rubygems"
14
39
  require "vagrant/util"
@@ -2,6 +2,7 @@ require 'vagrant/action/builder'
2
2
 
3
3
  module Vagrant
4
4
  module Action
5
+ autoload :Hook, 'vagrant/action/hook'
5
6
  autoload :Runner, 'vagrant/action/runner'
6
7
  autoload :Warden, 'vagrant/action/warden'
7
8
 
@@ -12,9 +13,12 @@ module Vagrant
12
13
  autoload :BoxCheckOutdated, "vagrant/action/builtin/box_check_outdated"
13
14
  autoload :BoxRemove, "vagrant/action/builtin/box_remove"
14
15
  autoload :Call, "vagrant/action/builtin/call"
16
+ autoload :CleanupDisks, "vagrant/action/builtin/cleanup_disks"
15
17
  autoload :Confirm, "vagrant/action/builtin/confirm"
16
18
  autoload :ConfigValidate, "vagrant/action/builtin/config_validate"
19
+ autoload :Delayed, "vagrant/action/builtin/delayed"
17
20
  autoload :DestroyConfirm, "vagrant/action/builtin/destroy_confirm"
21
+ autoload :Disk, "vagrant/action/builtin/disk"
18
22
  autoload :EnvSet, "vagrant/action/builtin/env_set"
19
23
  autoload :GracefulHalt, "vagrant/action/builtin/graceful_halt"
20
24
  autoload :HandleBox, "vagrant/action/builtin/handle_box"
@@ -32,6 +36,7 @@ module Vagrant
32
36
  autoload :SSHRun, "vagrant/action/builtin/ssh_run"
33
37
  autoload :SyncedFolders, "vagrant/action/builtin/synced_folders"
34
38
  autoload :SyncedFolderCleanup, "vagrant/action/builtin/synced_folder_cleanup"
39
+ autoload :Trigger, "vagrant/action/builtin/trigger"
35
40
  autoload :WaitForCommunicator, "vagrant/action/builtin/wait_for_communicator"
36
41
  end
37
42
 
@@ -122,6 +122,7 @@ module Vagrant
122
122
  # @return [Integer]
123
123
  def index(object)
124
124
  stack.each_with_index do |item, i|
125
+ return i if item == object
125
126
  return i if item[0] == object
126
127
  return i if item[0].respond_to?(:name) && item[0].name == object
127
128
  end
@@ -132,42 +133,162 @@ module Vagrant
132
133
  # Converts the builder stack to a runnable action sequence.
133
134
  #
134
135
  # @param [Hash] env The action environment hash
135
- # @return [Object] A callable object
136
+ # @return [Warden] A callable object
136
137
  def to_app(env)
137
- app_stack = nil
138
+ # Start with a duplicate of ourself which can
139
+ # be modified
140
+ builder = self.dup
138
141
 
139
- # If we have action hooks, then we apply them
140
- if env[:action_hooks]
141
- builder = self.dup
142
+ # Apply all dynamic modifications of the stack. This
143
+ # will generate dynamic hooks for all actions within
144
+ # the stack, load any triggers for action classes, and
145
+ # apply them to the builder's stack
146
+ builder.apply_dynamic_updates(env)
142
147
 
143
- # These are the options to pass into hook application.
144
- options = {}
148
+ # Now that the stack is fully expanded, apply any
149
+ # action hooks that may be defined so they are on
150
+ # the outermost locations of the stack
151
+ builder.apply_action_name(env)
145
152
 
146
- # If we already ran through once and did append/prepends,
147
- # then don't do it again.
148
- if env[:action_hooks_already_ran]
149
- options[:no_prepend_or_append] = true
153
+ # Wrap the middleware stack with the Warden to provide a consistent
154
+ # and predictable behavior upon exceptions.
155
+ Warden.new(builder.stack.dup, env)
156
+ end
157
+
158
+ # Find any action hooks or triggers which have been defined
159
+ # for items within the stack. Update the stack with any
160
+ # hooks or triggers found.
161
+ #
162
+ # @param [Hash] env Call environment
163
+ # @return [Builder] self
164
+ def apply_dynamic_updates(env)
165
+ if Vagrant::Util::Experimental.feature_enabled?("typed_triggers")
166
+ triggers = env[:triggers]
167
+ end
168
+
169
+ # Use a Hook as a convenient interface for injecting
170
+ # any applicable trigger actions within the stack
171
+ machine_name = env[:machine].name if env[:machine]
172
+
173
+ # Iterate over all items in the stack and apply new items
174
+ # into the hook as they are found. Must be sure to dup the
175
+ # stack here since we are modifying the stack in the loop.
176
+ stack.dup.each do |item|
177
+ hook = Hook.new
178
+
179
+ action = item.first
180
+ next if action.is_a?(Proc)
181
+
182
+ # Start with adding any action triggers that may be defined
183
+ if triggers && !triggers.find(action, :before, machine_name, :action).empty?
184
+ hook.prepend(Vagrant::Action::Builtin::Trigger,
185
+ action.name, triggers, :before, :action)
150
186
  end
151
187
 
152
- # Specify that we already ran, so in the future we don't repeat
153
- # the prepend/append hooks.
154
- env[:action_hooks_already_ran] = true
188
+ if triggers && !triggers.find(action, :after, machine_name, :action).empty?
189
+ hook.append(Vagrant::Action::Builtin::Trigger,
190
+ action.name, triggers, :after, :action)
191
+ end
192
+
193
+ # Next look for any hook triggers that may be defined against
194
+ # the dynamically generated action class hooks
195
+ if triggers && !triggers.find(action, :before, machine_name, :hook).empty?
196
+ hook.prepend(Vagrant::Action::Builtin::Trigger,
197
+ action.name, triggers, :before, :hook)
198
+ end
199
+
200
+ if triggers && !triggers.find(action, :after, machine_name, :hook).empty?
201
+ hook.append(Vagrant::Action::Builtin::Trigger,
202
+ action.name, triggers, :after, :hook)
203
+ end
155
204
 
156
- # Apply all the hooks to the new builder instance
157
- env[:action_hooks].each do |hook|
158
- hook.apply(builder, options)
205
+ # Finally load any registered hooks for dynamically generated
206
+ # action class based hooks
207
+ Vagrant.plugin("2").manager.find_action_hooks(action).each do |hook_proc|
208
+ hook_proc.call(hook)
159
209
  end
160
210
 
161
- # The stack is now the result of the new builder
162
- app_stack = builder.stack.dup
211
+ hook.apply(self, root: item)
163
212
  end
164
213
 
165
- # If we don't have a stack then default to using our own
166
- app_stack ||= stack.dup
214
+ # Apply the hook to ourself to update the stack
215
+ self
216
+ end
167
217
 
168
- # Wrap the middleware stack with the Warden to provide a consistent
169
- # and predictable behavior upon exceptions.
170
- Warden.new(app_stack, env)
218
+ # If action hooks have not already been set, this method
219
+ # will perform three tasks:
220
+ # 1. Load any hook triggers defined for the action_name
221
+ # 2. Load any action_hooks defined from plugins
222
+ # 3. Load any action triggers based on machine action called (not action classes)
223
+ #
224
+ # @param [Hash] env Call environment
225
+ # @return [Builder]
226
+ def apply_action_name(env)
227
+ return self if !env[:action_name]
228
+ hook = Hook.new
229
+ machine_name = env[:machine].name if env[:machine]
230
+
231
+ # Start with loading any hook triggers if applicable
232
+ if Vagrant::Util::Experimental.feature_enabled?("typed_triggers") && env[:triggers]
233
+ if !env[:triggers].find(env[:action_name], :before, machine_name, :hook).empty?
234
+ hook.prepend(Vagrant::Action::Builtin::Trigger,
235
+ env[:action_name], env[:triggers], :before, :hook)
236
+ end
237
+ if !env[:triggers].find(env[:action_name], :after, machine_name, :hook).empty?
238
+ hook.append(Vagrant::Action::Builtin::Trigger,
239
+ env[:action_name], env[:triggers], :after, :hook)
240
+ end
241
+ end
242
+
243
+ # Next we load up all the action hooks that plugins may
244
+ # have defined
245
+ action_hooks = Vagrant.plugin("2").manager.action_hooks(env[:action_name])
246
+ action_hooks.each do |hook_proc|
247
+ hook_proc.call(hook)
248
+ end
249
+
250
+ # Finally load any action triggers defined. The action triggers
251
+ # are the originally implemented trigger style. They run before
252
+ # and after specific provider actions (like :up, :halt, etc) and
253
+ # are different from true action triggers
254
+ if env[:triggers]
255
+ if !env[:triggers].find(env[:raw_action_name], :before, machine_name, :action).empty?
256
+ hook.prepend(Vagrant::Action::Builtin::Trigger,
257
+ env[:raw_action_name], env[:triggers], :before, :action)
258
+ end
259
+ if !env[:triggers].find(env[:raw_action_name], :after, machine_name, :action).empty?
260
+ # NOTE: These after triggers need to be delayed before running to
261
+ # allow the rest of the call stack to complete before being
262
+ # run. The delayed action is prepended to the stack (not appended)
263
+ # to ensure it is called first, which results in it properly
264
+ # waiting for everything to finish before itself completing.
265
+ builder = self.class.build(Vagrant::Action::Builtin::Trigger,
266
+ env[:raw_action_name], env[:triggers], :after, :action)
267
+ hook.prepend(Vagrant::Action::Builtin::Delayed, builder)
268
+ end
269
+ end
270
+
271
+ # If the hooks are empty, then there was nothing to apply and
272
+ # we can just send ourself back
273
+ return self if hook.empty?
274
+
275
+ # These are the options to pass into hook application.
276
+ options = {}
277
+
278
+ # If we already ran through once and did append/prepends,
279
+ # then don't do it again.
280
+ if env[:action_hooks_already_ran]
281
+ options[:no_prepend_or_append] = true
282
+ end
283
+
284
+ # Specify that we already ran, so in the future we don't repeat
285
+ # the prepend/append hooks.
286
+ env[:action_hooks_already_ran] = true
287
+
288
+ # Apply all the hooks to the new builder instance
289
+ hook.apply(self, options)
290
+
291
+ self
171
292
  end
172
293
  end
173
294
  end