3795 Commits

Author SHA1 Message Date
Jeff Bonhag
1e7399afa5
Merge pull request #11454 from jbonhag/fix/port-collision-net-test
Fix #11373: Check all interfaces for port collisions on Windows
2020-04-03 13:46:45 -04:00
Chris Roberts
b8702ac889 Include default options in option parser
Adds method to shared helpers for adding procs to be evaluated
which can add default modifications to the option parser used
by commands. Customized option parser class within Vagrant
handles processing defined procs to set options.
2020-03-27 16:57:59 -07:00
Jeff Bonhag
dfad00fd25
Include machine name in error message
This will make it easier for folks to debug networking settings.
2020-03-27 11:49:21 -04:00
Jeff Bonhag
00b72aa2c5
bug: test host platform, not guest platform 2020-03-20 09:56:43 -04:00
Jeff Bonhag
9c5291794a
Include interface names in debug log 2020-03-19 18:05:17 -04:00
Jeff Bonhag
6d228becf9
Raise an error if host IP is not found 2020-03-19 17:16:21 -04:00
Jeff Bonhag
705baaad46
Only do special 0.0.0.0 check on Windows hosts
If host_ip is nil or 0.0.0.0, only do the special port check on Windows
hosts, because non-Windows hosts can test 0.0.0.0 directly.
2020-03-18 17:39:33 -04:00
Jeff Bonhag
b8ecab1201
Guard against nil Addrinfo objects
On Windows, `Socket.getifaddrs` may return nil if the address is not available in ifaddr.
2020-03-13 17:34:09 -04:00
Jeff Bonhag
d4acdd06ec
Fix #11373: Check all interfaces for port collisions
This commit changes the behavior of the port check to check all possible
IPv4 network interfaces when the host IP is `nil` or `0.0.0.0`. This
means that if the desired port is available on any network interfaces, a
forward from 0.0.0.0 will use that interface.

If the port is open (in use) on all interfaces, then it's treated as a
collision and will either throw an error or auto-correct the port, based
on the Vagrantfile configuration.
2020-03-13 16:30:01 -04:00
Jeff Bonhag
6efdcd2068
Merge pull request #11430 from chrisroberts/winssh-hacks
Fix issues with Windows SSH provisioner (continued...)
2020-03-11 10:39:44 -04:00
Chris Roberts
21e5913cef Explicitly activate vagrant specification when not activated 2020-03-10 15:08:56 -07:00
Chris Roberts
9336ca5529
Merge pull request #11363 from chrisroberts/enhancement/solutions
Add support for caching solutions. Remove GEMRC modifications.
2020-03-10 14:42:28 -07:00
Chris Roberts
bee56a09df
Merge pull request #11366 from dmitrivereshchagin/fix-curl-invocation
Fix use of -q option in curl invocation
2020-03-09 16:53:12 -07:00
Chris Roberts
d96f7c4293 Fix documentation disable in generation hooks 2020-03-09 16:52:39 -07:00
Chris Roberts
351e053aeb Start adding test coverage to bundler class 2020-03-09 16:52:39 -07:00
Jeff Bonhag
df7c11a3a7 Fix issues with Windows SSH provisioner
Windows commands that run over SSH are wrapped in a script that writes a
special marker to the two output streams (stdout and stderr).  This
allows Vagrant to consume the output streams.

Unfortunately, this leads to a sort of chicken-and-egg problem where no
commands can be run before a wrapper script exists. For example, you
can't make a destination directory to upload the wrapper script without
first creating a wrapper script to make the directory. :)

This commit changes the behavior of the WinSSH communicator to assume
that the destination directory already exists for provisioning scripts.

It also moves the default `upload_path` from the shell provisioner
config so we can have OS-specific defaults.

Finally, it introduces a Windows-specific #upload method which will
properly use a Windows path separator on a non-Windows host.
2020-03-04 15:08:03 -08:00
Chris Roberts
98f0ec6ab7 Dynamically apply hooks to actions prior to execution
Removes dynamic calls of before/after hooks and replaces it with
proper lookups for hooks defined for the action to run. If hooks
are found for an action, the action is placed in a new builder
and the hooks are applied. The new stack is extracted, finalized,
and then executed.
2020-03-03 16:23:31 -08:00
Chris Roberts
2ac12cfde8 Add new hook lookup method and key generation helper 2020-03-03 16:13:41 -08:00
Chris Roberts
2186e92539 Add Hook class to the autoload list 2020-03-03 16:13:13 -08:00
Jeff Bonhag
08c3c741fe
Fix #11396: Use sudo to detect if systemd in use (#11398)
This change allows the vagrant user to see the systemd process in the
event that the hidepid mount option is enabled.

Also adds sudo: true to other tests that use `systemd?`
2020-02-14 12:10:59 -05:00
Brian Cain
8af2e5c8be
Cast to float on conversation, and return helper size vars to integer 2020-02-10 13:01:41 -08:00
Brian Cain
9150d3db7b
Always cleanup disks even if no disks in Vagrantfile 2020-02-10 12:58:11 -08:00
Brian Cain
eff3d47f82
Add cleanup_disks test 2020-02-10 12:58:11 -08:00
Brian Cain
ca26afa299
Don't write disk_meta file if no disks to configure 2020-02-10 12:58:11 -08:00
Brian Cain
2176216bf8
Add error for when disks defined are greater than the max limit 2020-02-10 12:58:11 -08:00
Brian Cain
6ba621ac92
Add ability to cleanup and close mediums for a guest 2020-02-10 12:58:11 -08:00
Brian Cain
ad798c2c12
Pass in disk meta file for cleanup_disks 2020-02-10 12:58:11 -08:00
Brian Cain
e4a57a8e1d
Add virtualbox cleanup_disks action 2020-02-10 12:58:11 -08:00
Brian Cain
cc8ed8a616
Add cleanup_disks action 2020-02-10 12:58:11 -08:00
Brian Cain
5bf8d2363e
Update logger message 2020-02-10 12:58:11 -08:00
Brian Cain
ec350861cd
Write down metadata for disk configs after configuring disks 2020-02-10 12:58:11 -08:00
Brian Cain
81095090a0
Remove unused function 2020-02-10 12:58:11 -08:00
Brian Cain
35c8db56ec
Add handling for configuring and creating disks with vbox provider 2020-02-10 12:58:11 -08:00
Brian Cain
5273ba9590
Add method for converting bytes to megabytes 2020-02-10 12:58:11 -08:00
Brian Cain
00b47a285e
Ensure decimal points are respected for numeric conversions 2020-02-10 12:58:11 -08:00
Chris Roberts
21c1bb5e05 Add support for caching solutions. Remove GEMRC modifications.
This pull request adds an enhancement to the internal Bundler class
to cache solution sets. This prevents Vagrant from generating a
solution for configured plugins on every run. Modifications to
the configured plugin list (global or local) will result in the
cached solution being invalidatd and resolved again.

Also included is the removal of the GEMRC modifications required
for Windows.
2020-02-03 07:43:17 -08:00
Dmitri Vereshchagin
8befc12830 Fix use of -q option in curl invocation
curl ignores -q if it's not the first option.  Thus, prior to this
change, curl configuration file is used while performing HEAD request.
2020-02-03 00:00:36 +03:00
Brian Cain
6855dd8c74
Check name config option with respond_to?
Prior to this commit, the check used to look for the config option
`name` in a provisioner config would accidentally create a "DummyConfig"
based on how vagrant handles missing config options. This commit fixes
that by instead using the `respond_to?` method to check for the
existance of the config option name.
2020-01-07 11:10:02 -08:00
Brian Cain
711270b90a
Fixes #11287: Set top level provisioner name if set in provisioner
config

Prior to this commit, if a user had configured a provisioner that had a
config with a `name` option, it would not properly set the top level
provisioner classes name config option which would lead to some
understanibly confusing results when trying to `--provision-with`. This
commit fixes that by checking to see if the top level name isn't set,
look to see if that provisioners config defines a name, and use that
instead.
2020-01-06 11:10:28 -08:00
Jeff Bonhag
7fb7dd8608
Enable WinSSH shell for vagrant ssh -c (#11258)
This commit changes the behavior of the builtin SSHRun action to use a Windows
shell if the WinSSH communicator is active.  This allows for running one-off SSH
commands with Windows Command Prompt or PowerShell.  By default, this will not
allocate a TTY for any SSH commands.

Example usage:

```
vagrant ssh -c 'dir "c:\program files"'
```

Updates docs to reflect a change made in
a55a53e6a46438d5093487f83248f01ddece4534.
2019-12-20 13:10:11 -05:00
Jeff Bonhag
ade076cabb
Fixes #11236: Windows port detection (#11244)
This reverts commit 81553263ab812a7fd0a2ab0f627bee139ad6397c.

This fixes a regression with Windows port detection which led to port
collisions not being fixed on `vagrant up`.

PR #8517 changed `IsPortOpen#is_port_open?` to rescue
Errno::EADDRNOTAVAIL, but when we merged it into master, there was code
in `HandleForwardedPortCollisions#port_check` that depended on that
error bubbling up.
2019-12-19 14:46:13 -05:00
Chris Roberts
80c05460ab Call hooks before and after each action if they are available 2019-12-18 13:11:30 -08:00
Brian Cain
61ee42976b
Merge pull request #11262 from briancain/return-if-no-disk-config
Return if no disk config
2019-12-17 13:55:08 -08:00
Brian Cain
de61b307aa
Only run disk action if disk config present 2019-12-17 10:45:33 -08:00
Jeff Bonhag
d7a5f74897
Fixes #11128: Error if machine folder inaccessible (#11239)
This commit catches the Errno::EPERM raised by the operating system if
the machine folder is inaccessible and displays it as a more friendly
error message.

This can be an issue on macOS Catalina if virtual machine files are kept
in a special directory (Documents/Downloads/Desktop) that Vagrant's
embedded Ruby is not allowed to access.
2019-12-17 12:41:12 -05:00
Brian Cain
bcf4d5a210
Fixes #11228: Allow to force check for box updates
Prior to this commit, if a user had recently checked for updates, there
was no way to force Vagrant to re-check without manually deleting a
state file in the local `.vagrant` data dir. This commit fixes that by
giving users the ability to force check for updates for a given box with
a flag to the `vagrant box outdated` command.
2019-12-03 11:42:55 -08:00
Brian Cain
f979d40436
Add warning if machines provider does not support disk configuration 2019-11-22 14:40:23 -08:00
Brian Cain
8ad810b5b6
Check and call into provider capability :configure_disks 2019-11-22 14:40:23 -08:00
Brian Cain
2e324a4971
Add conversion method for shortcut size in disk config 2019-11-22 14:40:23 -08:00
Brian Cain
271cf8a603
Begin to add Numeric class helper for converting size strings 2019-11-22 14:40:23 -08:00