Packaging an existing vagrant environment relied on copying the backing
image. Users may not have permission to read this file despite being
able to interact with it through libvirt.
Use ruby-libvirt to download the image instead so any user with libvirt
access can run the package command.
Uncomment NFS prune action
If the user has not configured NFS for any of the synced folders, then
it is likely they are not expecting to be asked for a sudo password on
destroy. Move the test for using NFS to a common module and include in
both the preparing and pruning actions.
Co-authored-by: Darragh Bailey <daragh.bailey@gmail.com>
The fog-libvirt volumes filter behaves differently than the others in
that it returns an empty volume object if nothing is found. This has the
potential to change in the future so guard against an empty result as
well by checking if the assigned first element is nil.
This commit replaces the pattern where the metadata for all volumes,
servers, or pools was downloaded and then searched. Instead a filter
argument is passed to the connection and only the metadata for the named
resource is returned, if it exists. This results in significant speed
increases for libvirt hosts that are offsite or have many volumes.
Latest vagrant depends on a vagrant-spec release containing a more
recent dependency on childprocess than is supported for earlier releases
of vagrant.
Adjust dependencies to pin to the specific release of vagrant-spec if
the request version of vagrant is 2.2.7 or older.
Does not attempt to handle the situation where a version is specified
that cannot be parsed.
While it would be useful to test against newer versions of 2.2.x, it
appears this encounters a bug in upstream vagrant when installing in
dev mode see https://github.com/hashicorp/vagrant#11293
Therefore limit latest 2.2.x released version tested against to 2.2.4.
Warden will call the recover method when env[:interrupted] is set, so
just return instead and let it walk the stack to perform cleanup. This
ensures that during the WaitTillUp action that the user setting to
disable destroy_on_error is respected should the exception occur during
looking for the IP address or SSH connection.
Checking if a volume exists before attempting to create it results in
a "time of check to time of use" race. When the check is done the
volume doesn't exist but then, because it is shared storage, it is
then created by another node before the local attempt to create it.
This results in an unexpected failure.
It is better to simply attempt to create the volume and ignore EEXIST
in cases where this is permissible.
Implementing this properly is complicated by the fact that the
exception appears to contain only an error message and does not appear
to contain a useful error code. Digging through the layers in, for
example, fog-libvirt provides no evidence why this is so. However,
the error message seems fairly unique and matching it is easy, so just
do that. A small hack to vastly improve stability.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Support `vagrant package` of e.g. bento-derived boxes that require SSH
hostkeys already set (as in the case of bento/debian-7 and above,) as
well as leave existing LVM UUIDs untouched (e.g. in bento/ubuntu-18.04.)
Instead of hard-coding sysprep operations, use an environment variable
to set these instead.
Use the Chef bento use case as an example for customizing sysprep
operations.
Default to using the same storage pool in case the user defines
storage_pool_name without defining snapshot_pool_name and only use a
separate pool when snapshot_pool_name is explicitly set.
This will ensure that setting storage_pool_name to a different pool does
not also require setting snapshot_pool_name to match previous behaviour.
Additionally it is reasonable for a user to assume that if a Vagrantfile
sets storage_pool_name to something other than 'default', then there
should be no need for a default pool.