The docs for Ruby say Pathname#rmtree will recursively delete, but
apparently that is a lie, at least on Windows (see GH-7496). Switch to
using FileUtils to ensure the directory is deleted.
Fixes GH-7496
This commit changes Vagrant::Util::Platform to cache the result of some
common operations. These values are highly unlikely to change over the
course of a single Vagrant run and they are only cached for that run.
This adds two new SSH configuration options:
- `keys_only`
- `paranoid`
These values were previously hard-coded, but can now be user-specified.
Fixes GH-4275
This commit basically grepped the code base for all uses of Dir.mktmpdir
and Tempfile.new/open and ensures the value is unique within the
code base and also prefixed with `vagrant-`.
Previously, most invocations of these commands simply used "vagrant",
thus making them indistinguishable when trying to identify leaks.
The only reason we were using Tempfile was to generate the path. This
commit switches to using `Dir::Tmpname.create`, which accomplishes the
same thing without the overhead of creating and removing a tempfile.
This commit separates the scratch and output directory creation from the
main package middleware into its own PackageSetupFolders middleware.
Additionally, the validation that ensures an output file does not exist
is moved into a validation function that can be shared across multiple
methods.
This refactor permits a pre-flight check to ensure box packaging would
be successful before actually stopping the VM.
Fixes GH-7351
This commit bumps the box resume delay time to 24h and makes it a
constant because I had a bugger of a time actually finding this in the
code :frowny:.
Fixes GH-7272
Ensure multi machine access of other machine state information through
iterating `active_machines` and retrieval of cached machines cannot
have multiple threads update the state of machines simultaneously as
this triggers a Machine Lock exception.
Machine state information retrieved from the index, returns a locked
object. Since iteration of active_machine, and retrieval of each
machine from the cache can be triggered by any plugin, it is possible
for another machine to inadvertently access the state and trigger an
update, which the thread owning the machine is currently in the process
of updating it already. This results in a Machine Locked exception
occurring if the attempt to retrieve the cached state from the index
occurs before the other thread calls release.
Partially-Fixes: #6526
Without this change, the version string may be mutated when passed through
Gem::Version.new(version).to_s before being used to construct the box
directory. This is a problem when using prerelease version numbers because,
for example, it will look for "~/.vagrant.d/boxes/1.0.0.pre.alpha.1" when it
should be looking for "~/.vagrant.d/boxes/1.0.0-alpha.1".
This helps with some confusion caused in GH-2538, since the output says:
> Running cleanup tasks for 'shell' provisioner...
But that's actually not true. It is running the cleanup tasks iff the
provisioner defined a cleanup task. This commit changes the
provisioner_cleanup middleware to only run cleanup tasks if the subclass
defines a cleanup task.
The reason we can't just check if the provisioner `respond_to?` the
`cleanup` method is because the parent provisioner base class (which
all provisioners inherit from) defines a blank cleanup method. This is
important because it means we never risk calling an unimplemented
cleanup function, and it also helps define the public API for a
provisioner.
This patch introduces a new parameter --all for the remove
command of the box plugin. Setting this parameter will remove
all available versions of a specific box.
Example usage:
```
$ vagrant box list
ubuntu/trusty64 (virtualbox, 20150427.0.0)
ubuntu/trusty64 (virtualbox, 20150430.0.0)
ubuntu/trusty64 (virtualbox, 20150506.0.0)
```
```
$ vagrant box remove ubuntu/trusty64
You requested to remove the box 'ubuntu/trusty64' with provider
'virtualbox'. This box has multiple versions. You must
explicitly specify which version you want to remove with
the `--box-version` flag. The available versions for this
box are:
* 20150427.0.0
* 20150430.0.0
* 20150506.0.0
```
With the --all parameter it is possible to remove all versions at once.
```
$ vagrant box remove --all ubuntu/trusty64
Removing box 'ubuntu/trusty64' (v20150506.0.0) with provider 'virtualbox'...
Removing box 'ubuntu/trusty64' (v20150430.0.0) with provider 'virtualbox'...
Removing box 'ubuntu/trusty64' (v20150427.0.0) with provider 'virtualbox'...
```
With this change, the existing host-based Ansible provisioner is
refactored to share a maximum of code with this new guest-based Ansible
provisioner.
At this stage of development, the existing unit tests are intentionally
modified as little as possible, to keep safe the existing funtionalities.
Other issues resolved by this changeset:
- Display a warning when running from a Windows host [GH-5292]
- Do not run `ansible-playbook` in verbose mode when the `verbose` option
is set to an empty string.
Changed the name of the error LinuxRDesktopNotFound to
LinuxRDPClientNotFound and re-worded error text in
templates/locales/en.yml to include `xfreerdp` when listing supported
RDP clients.
This causes issues since the child environment almost certainly doesn't
share data with the parent. In a larger scope, we should find a way to
encode the data path somehow on `vagrant up`.