hashicorp/vagrant#11465 introduced a new option --no-tty which silences
progress bars so they don't spam logs when Vagrant is used
non-interactively. First Vagrant version with this change is v2.2.8.
However, existing code needs to be slightly updated to cooperate with
the new option correctly, otherwise the progress bars spam the logs with
empty lines/warnings instead of remaining silent.
Fixes: #1106
Add default domain start spec test and fix bug triggered by whitespace
mismatch in string comparison that would trigger unexpected domain
undefine and recreate.
Switch to looking up the version from a file with a fall back to get
it directly from git tags if the file isn't available.
The version file is automatically generated by a task of building of the
gem and included in the package release to prevent reading from git.
Should allow the release process to be automated from pushing of a git
tag.
Add support for a pool setting for additional disks, example:
Vagrant.configure("2") do |config|
config.vm.box = "generic/centos8"
config.vm.provider :libvirt do |domain|
domain.storage :file, :size => '20G', :pool=>'default'
domain.snapshot_pool_name='cache'
end
end
this allows to place the virtual machines snapshot in the "cache" pool,
while additional disks are created in the "default" storage pool.
Provide a simple create domain test that uncovered a bug with an
exception in addition to fixing the tests to avoid unnecessary output
when the code sends messages via the UI.
Erubis is dead upstream, therefore it is good idea to avoid its usage.
Also, this allows to drop explicit dependency on Erubis, which is not
specified anywhere and may cause issues when Vagrant changes its
renderer.
Fixes#1142.
Users are allowed to set a LIBVIRT_DEFAULT_URI environment variable that
controls tools (i.e. virsh, virt-install, etc) that communicate with
libvirt. Let's allow for that mechanism to be used here.
Test settings modifying the `@uri` and `@qemu_use_session` variables to make
it easier to update and perform an initial minor refactor to reduce some
of the code currently in use to set `@uri`.
According to the docs, for volumes and backingStores: "The mode defaults to
0600 when not provided. https://libvirt.org/formatstorage.html
Removing this setting here allows the pool configuration to set the default
mode.
- Explicitly disable any SSH multiplexing here so PID tracking of
tunnels works correctly.
- Using `exec ssh` in the spawn forces Ruby to use a subshell (as exec
is a shell builtin) instead of spawning the ssh process directly, which
results in getting the wrong (and dead, as the exec replaces the
subshell) PID to track and clean up later.
- Run the ssh tunnel command on its own process group, essentially
daemonizing it and keeping its PID intact even when `vagrant up` command
is run on shell/consoles without an explicit TTY, such as Emacs Eshell.
Make it easier to tweak some qemu options by allowing passthru of
command line environment variables.
- Also cleans up weird variable indirection used for qemu commandline args
variable through `qargs` in various constructors.
- Addresses some functionality discussed in #776.
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.
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.
the 'echo' service is often not available out-of-the-box,
so the 'ping' of the ssh interface fails. This results in the
wrong ip addresses being used in /etc/exports, which results in
the vm not being able to mount the vagrant shares.
The 'vagrant ssh interface' will have the service 'ssh' available
(you won't be able to login to your vagrant box else), so it makes
sense to use that service for the ping.
This fixes the vm not being able to mount the shares over nfs after
a reload due to the wrong ip addresses being used.