Commit Graph

784 Commits

Author SHA1 Message Date
Frantisek Sumsal
308ead403e Support the newly-introduced --no-tty Vagrant's option (#1120)
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
2020-11-16 15:32:47 +00:00
Michael Ablassmeier
027910d236 Support setting ovs interface id (#1156)
Support setting the ovs interfaceid parameter

Fixes: #1155
2020-11-16 15:11:59 +00:00
Darragh Bailey
71503ed62e Rudimentary start domain action spec (#1167)
Add default domain start spec test and fix bug triggered by whitespace
mismatch in string comparison that would trigger unexpected domain
undefine and recreate.
2020-11-15 23:28:43 +00:00
Darragh Bailey
966ef2a534 Tag version from git tag (#1161)
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.
2020-10-23 18:18:52 +01:00
Michael Ablassmeier
70bb392241 Support separate storage pools for additional disks (#1130)
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.
2020-10-23 14:39:14 +01:00
Darragh Bailey
06e31d3918 Add rudimentary create domain spec test (#1158)
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.
2020-10-23 14:31:29 +01:00
Darragh Bailey
2f827fa5a3 Update version for release (#1151) 2020-10-03 21:14:00 +01:00
Vít Ondruch
0ecb9cc94f Use Vagrant::Util::TemplateRenderer instead of Erubis. (#1144)
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.
2020-10-03 21:04:59 +01:00
Darragh Bailey
d7debb68c6 Merge pull request #1123 from cvoltz/wwn
Add WWN support
2020-08-16 19:49:15 +01:00
Dusty Mabe
41bcae26e4 config: allow for setting URI from environment
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.
2020-08-16 16:37:57 +01:00
Darragh Bailey
d16bdcc1dc Add @uri config tests and minor refactor (#1139)
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`.
2020-08-16 16:27:27 +01:00
Rui Lopes
19cd1d5629 let the user set the domain title and description 2020-08-12 22:06:05 +01:00
Hans-Christoph Steiner
8b712b7715 remove redundant setting of default volume/backingStore mode
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.
2020-07-22 13:45:38 +02:00
Christopher Voltz
437fc3f3b0 Add WWN support
Add the disk attribute wwn to set the WWN of a disk drive.

Signed-off-by: christopher@voltz.us
2020-06-14 20:00:15 -05:00
Zak B. Elep
55abd327eb Add public_address provider capability
Used by vagrant-share plugin to determine local guest address for
forwarding via ngrok.
2020-06-04 17:07:40 +08:00
Zak B. Elep
9e35ec2b05 action/forward_ports.rb: Fix SSH tunnel spawning and PID tracking
- 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.
2020-05-28 17:26:50 +08:00
Darragh Bailey
aa7ea05540 Bugfix release 0.1.2 (#1112)
Skipping 0.1.1 as accidentally tagged before bumping version
2020-05-12 10:05:32 +01:00
Philippe Vanhaesendonck
4472654ba0 prune_nfs_exports: create Logger instance.
Fix #1110

Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@e-bulles.be>
2020-05-12 08:33:39 +02:00
Julio Lajara
f00bc0eaae Add qemu commandline environment variable support. (#961)
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.
2020-05-10 14:37:31 +01:00
ryanfitzsimon
a83900f1ae Download images with libvirt instead of copying (#928)
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.
2020-05-10 13:13:56 +01:00
Quinten Johnson
7e966febbd Allow setting of PCI domain (#927) 2020-05-10 11:40:29 +01:00
Quinten Johnson
618c8b251d Allow specification of domain shares (#925)
Weighted priority of the domain relative to others on the host.
2020-05-10 11:24:06 +01:00
Quinten Johnson
d9c5f63410 Allow specification of numa nodeset (#924)
This specifies the physical numa nodes on which the virtual memory can be
placed.
2020-05-10 10:52:46 +01:00
Quinten Johnson
60ef4b03d1 Allow specification of cpuset (#923)
Allows the pinning of vcpus to physical cpus.
2020-04-29 19:08:01 +01:00
Darragh Bailey
47ded9f52e Make sure to require util/nfs for include (#1103) 2020-04-29 17:03:47 +01:00
Paul Elliott
bde81a15a2 Remove NFS exports on domain destroy (#781)
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>
2020-04-28 16:22:34 +01:00
Chris Crebolder
34d933deea Check for empty result from fog-libvirt volumes
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.
2020-04-24 21:10:29 +01:00
Chris Crebolder
86aac4ce9c Use fog-libvirt filters when querying libvirt host
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.
2020-04-24 21:10:29 +01:00
Michael Ablassmeier
304a2a055c call stale_volume_remove only if configured libvirt pool exists (#1095)
Move message about removing stale volume unless there is one to be
removed.
2020-04-24 19:11:19 +01:00
Darragh Bailey
5e1445f7df Prep for releasing 0.1.0 (#1093)
Start keeping .1 for bugfixes and make it easier for people to pin locally to accept those without picking up major changes
2020-04-23 18:07:09 +01:00
Darragh Bailey
8cea27fd3e Defer to Warden to call recover (#984)
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.
2020-04-22 09:13:18 +01:00
Darragh Bailey
30ccf3a0ba Merge pull request #1096 from abbbi/handle_box_image
Fixes issue introduced with #1030
2020-04-21 17:58:28 +01:00
Michael Ablassmeier
59ef20812b fix handle_box_image.rb:89: syntax error 2020-04-21 13:49:29 +02:00
Michael Ablassmeier
d39a9a302a Allow setting of Sysprep options and multiple hyperv features (#1089)
Allow setting of multiple hyperv features and support for virt-sysprep options

Fixes #1039 and #1077
2020-04-21 11:37:03 +01:00
Darragh Bailey
4598cfc280 Merge pull request #974 from electrofelix/match-storage-pool-by-default
Default to storage pool if snapshot pool not defined
2020-03-27 18:34:33 +00:00
Darragh Bailey
2f2262774e Merge pull request #1030 from voxik/use-fog-libvirt-for-volume-management
Use fog-libvirt facilities to create volumes for QEMU session.
2020-03-27 18:30:33 +00:00
Tadej Janež
f8eae9984d Use fetch to obtain environment variable value in package_domain (#1035)
ENV is a Ruby Hash which doesn't have a get method but the fetch method.
2019-08-13 12:06:19 +01:00
Vít Ondruch
608037c15c Use fog-libvirt facilities to create volumes for QEMU session.
This is supported since fog-libvirt 0.6.0 via https://github.com/fog/fog-libvirt/pull/60
2019-07-17 18:27:00 +02:00
Darragh Bailey
8e85d0fc8c Merge pull request #985 from martin-schwenke/master
Avoid TOCTOU error in volume creation
2019-05-10 14:18:29 +01:00
Martin Schwenke
222b50925d Avoid TOCTOU error in volume creation
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>
2019-03-13 21:50:13 +11:00
Darragh Bailey
8f314cbb0e Fail on port collisions
Partial Fix #321 by enabling option ExitOnForwardFailure=yes to detect
and fail on forward port mappings failing to bind.
2019-03-06 11:34:23 +00:00
Zak B. Elep
deb36bef8b Allow customizing of virt-sysprep behaviour on package (#955)
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.
2019-02-27 12:32:37 +00:00
Darragh Bailey
4d2c26a926 Merge pull request #895 from mattandersen/default-forward-all-nics
Default Port Forwarding to All Host Addresses
2019-02-18 12:19:28 +00:00
Darragh Bailey
e40f1c67b4 Default to storage pool if snapshot pool not defined
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.
2019-02-13 16:52:20 +00:00
Darragh Bailey
c02905be14 Merge pull request #885 from brianjmurrell/patch-1
Don't add _ after user defined default_prefix
2019-02-13 15:24:42 +00:00
Evgeni Golov
53539f6ad4 add domain name for the management network
this allows users to have a dedicated domain for their vagrant VMs and
point their regular resolver at the libvirt dnsmasq for that domain to
make them reachable by a full name instead of the IP when accessing the
services on said VM.

an example for such a setup can be found in [1] and [2]

[1] https://liquidat.wordpress.com/2017/03/03/howto-automated-dns-resolution-for-kvmlibvirt-guests-with-a-local-domain/
[2] https://m0dlx.com/blog/Automatic_DNS_updates_from_libvirt_guests.html
2019-02-13 15:51:26 +01:00
Daniel T Chen
41e5b2f362 Updated Libvirt-based Vagrant box search reference and edited names for consistency 2019-02-11 20:18:02 -05:00
Peter Slootweg
c1d2144ec2 check for 'ssh' service to see if interface is up
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.
2019-01-17 09:38:34 +01:00
Michael Ablassmeier
d5ba63d413 #952 : support different storage pool for base box snapshot (#953) 2018-12-04 17:43:38 +01:00
Darragh Bailey
a725092ee9 Merge pull request #883 from pennsignals/fix/clean-forwarded-ports-darwin
Use ps keyword `command` instead of `cmd`
2018-11-27 19:19:47 +00:00