Commit Graph

1413 Commits

Author SHA1 Message Date
Mikhail Ushanov
5019e282f2 fix(action): fix typo in change domain disk_bus
Signed-off-by: Mikhail Ushanov <gm.mephisto@gmail.com>
2021-08-04 13:41:27 +03:00
Darragh Bailey
319c4f14c3
Merge pull request #1330 from dcermak/bump-rspec
Unrestrict rspec-* version to >= 3.5 to sync with vagrant
2021-08-04 08:56:11 +01:00
Dan Čermák
d6c603b163
Unrestrict rspec-* version to >= 3.5 to sync with vagrant
Vagrant recently bumped its minimum rspec version to 3.10. This commit
unrestricts the version so that the requirements from old and new vagrant
versions can be accommodated.
2021-08-04 09:27:14 +02:00
Darragh Bailey
4feb0424cd
Bump vagrant version and update README (#1321)
Update to the latest vagrant release and adjust README to align for
latest changes for the docker container.
2021-07-01 10:53:50 +01:00
Darragh Bailey
1f51841678
Use working directory for user/group resolution (#1320)
To handle where the ~/.vagrant.d global state directory for a user
doesn't exist, and thus specifying it as part of the docker run command
will result in the docker daemon creating it with root ownership.

Switch to using the working directory for user/group resolution,
searching for the Vagrantfile in the starting path and then working
up the tree. If it's not found default to the original starting path.

Combined with checking if the mounted vdir is empty, use the resolved
user/group based on the Vagrantfile and working directory to modify the
newly created directory to belong to the running user. Subsequently
ensure that the directories referenced via symlinks are created if they
don't exist.

Fixes: #1191
Closes: #1254
2021-06-30 17:56:09 +01:00
Darragh Bailey
18ebb9d9ed
Enable frozen string across project (#1319)
Turn on frozen string support in all files by using a comment to avoid
enabling across dependencies where it may not work.

Fixes: #1177
2021-06-30 13:27:03 +01:00
Darragh Bailey
6dac9c9054
Remove debug statement accidentally left behind (#1318)
Prune debug print statement added by #1308.
2021-06-29 13:51:29 +01:00
Darragh Bailey
1174685e7b
Basic packaging tests and restructure action (#1307)
Restructure action to remove custom handling around packaging of the
box and instead use more of the built-in provided actions instead.

Includes some packaging tests to cover both simple where the public
key is retained (can't modify the tinycore VM without more complex
provisioning steps), and a more complex one that utilizes a script
and supports triggering regenerating the hosts on subsequent boots.

The use of the upstream packaging helpers means that when the
default insecure ssh key has been replaced, the packaging process
will automatically include the generated key.

Fixes: #759
Fixes: #765
Fixes: #1013
Fixes: #994
2021-06-25 20:01:02 +01:00
Darragh Bailey
192eefcfbf
Default to build and publish extendible image (#1246)
Switch to publishing the image containing all of the libraries and build
dependencies needed to support the plugin being reinstalled as that is
the default behaviour when vagrant installs a new plugin.

This should allow the default image to be extended with additional
plugins and if needed, the authors of the new image may follow and use
the slim version as a base to provide a reduced size docker image.

Fixes: #1198
2021-06-25 19:28:17 +01:00
Darragh Bailey
8defd28871
Disable removal of host keys by default (#1315)
Testing has shown that most boxes do not have the hosts keys removed as
it is non trivial to get them to regenerate on subsequent bring up.
Additionally vagrant uses `StrictHostKeyChecking=no` to ignore the host
keys so relying on them to provide any kind of security or identity of a
VM is pointless.

In the few cases where it is possible to have keys regenerate it should
be managed by how the box is cleaned up, and otherwise forced by a
provision script on first boot of the VM.

While it is possible to have a script executed via sysprep modify the
boot of the machine to ensure the keys are regenerated on the next boot,
this should either be built-in to occur automatically, and there by
assume the responsibility for ensuring host keys are replaced for each
VM packaged by vagrant-libvirt, or should default to the same behaviour
that appears to be common for many debian based boxes and simply not
attempt to remove the host keys. If removal is useful, it may be
re-enabled as needed. See #851 for a script that can be used to have
openssh-server reconfigured to trigger regenerating the keys.

A number of people have tried to fixed this previously and I failed to
understand then that they were correct. Have attributed co authorship of
this to all of the PRs authors that attempted to fix this over the
years.

Related: #759
Related: #873
Related: #955
Related: #994

Co-authored-by: Guillaume Penaud <gpenaud@xilopix.com>
Co-authored-by: Zak B. Elep <zakame@zakame.net>
2021-06-25 11:30:59 +01:00
Darragh Bailey
06fef8ba46
Allow rspec to float on minor releases (#1316)
To ensure the tests can be run across multiple vagrant releases, must
allow newer rspec minor releases. As these are for development, it
should be alright to allow a wider range.
2021-06-25 11:20:59 +01:00
Darragh Bailey
1e4eeb6f8b
Merge pull request #1309 from yamatoRT/dev/bugfix-1308
Uses the json output of qemu-img info for read virtual size of disk.
Adds new ByteNumber for convert the virtual size to gygabyte, byte
and megabyte. Internally virtual size is now byte and not gigabyte.
2021-06-11 22:32:29 +01:00
Richard Turc
00cd79aa35 Use qemu-img json output and compute virtual size #1308 2021-06-11 16:38:35 +02:00
Darragh Bailey
e9f5f028a3
Ensure open3 required and qemu-utils in docker (#1306)
Depending on load order of libraries as well as version of ruby, need to
require open3 before attempting to reference `Open3`.

There is an additional dependency on qemu-utils to dynamically retrieve
the image information to provide the virtual size and format
automatically. Add this to the docker image to ensure it's available for
users of this distribution format.

Fixes: #1305
2021-06-07 15:31:18 +01:00
Darragh Bailey
af738b84eb
Merge pull request #1304 from s-vx/patch-1
Fix minor typo in README.md
2021-06-04 20:14:32 +01:00
s-vx
e6c68358cf
Fix minor typo in README.md 2021-06-04 13:10:53 -04:00
Darragh Bailey
31cc8aa91e
Add basic vagrant package integration test (#1302)
Simple integration test for vagrant package to ensure the execution
completes successfully to allow for some refactoring to be performed.

Ensure libguestfs-tools installed to provide virt-sysprep for tests and
update docs to reflect.
2021-06-01 17:45:02 +01:00
Darragh Bailey
dbbfad2503
Generate test matrix dynamically from bats (#1303)
Extract the tests to be run and generate the matrix dynamically to avoid
needing to update the list within the workflow for each test added.
2021-06-01 17:21:15 +01:00
Darragh Bailey
0c35a1e275
Vagrant up expects machine data_dir to exist afterwards (#1298)
Ensure the machine data_dir is recreated after removal because vagrant
up expects the directory to exist even if there has been an exception
and the machine has been deleted subsequently.
2021-05-28 15:40:34 +01:00
Darragh Bailey
199bfe19f9
Provide Vagrantfile path in description by default (#1299)
Ensure the source Vagrantfile appears in the virtual machine description
to help people using virsh/virt-manager subsequently to understand where
machines have come from.

Fixes: #496
2021-05-28 14:46:57 +01:00
Darragh Bailey
994f95e24f
Handle extraction of keyfile from uri (#1297)
If the keyfile is specified as part of the URI provided, extract it and
set the appropriate option so that it can be provided to the proxy
command subsequently.
2021-05-27 18:28:12 +01:00
Darragh Bailey
daa8f8af55
Handle custom port for remote libvirt (#1296)
Extract the port number from the parsed URI as part of finalizing the
uri and associated options. Don't expose this as a separate item to be
set as it can be passed in as part of the host entry.

Closes: #789
2021-05-27 17:28:25 +01:00
Darragh Bailey
3ff5795528
Add myself to the gem authors (#1295)
So that it's reflected on rubygems.org, add myself to the gem authors.
2021-05-27 17:09:32 +01:00
Darragh Bailey
5fdda391e2
Merge pull request #1294 from rgl/rgl-add-public-network-boot
add support for boot 'network' from a vagrant public_network
2021-05-27 10:42:44 +01:00
Rui Lopes
c96364575a add pxe boot public_network example 2021-05-27 07:42:04 +01:00
Rui Lopes
dba31833a4 add support for boot 'network' from a vagrant public_network
when use a public_network in vagrant, this is how libvirt domain xml looks like (notice that the interface type is 'direct'):

    <interface type="direct">
      <mac address="08:00:27:00:00:01"/>
      <source dev="br-rpi" mode="bridge"/>
      <model type="virtio"/>
      <boot order="2"/> <!-- this boot xml node will be inserted with this commit -->
      <address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0"/>
    </interface>
2021-05-26 07:59:47 +01:00
Darragh Bailey
7ce85f2216
Make disks attribute path required check for name collisions (#1293)
Ensure the path attribute for disks in the new format is required to
ensure there is always one parameter required for the hash element in
the array of disks. This avoids a certain amount of magical behaviour.

Identify that the name attribute is optional, however add checks for
collisions in volume names generated, as well as ensuring the volumes
are still prefixed in a way to prevent accidental collisions between
boxes utilizing the same names.

Add notes to the README identifying the format as experimental, with
notes on how the format should appear.
2021-05-22 16:59:11 +01:00
Darragh Bailey
1fe5a80516
Ensure state is correct reflected in global-status (#1292)
Vagrant relies on the side effect of checking the machine state to
trigger updating of the state in the global machine index. As a
consequence any action should not inspect the domain state directly and
instead should access the machine state.

Additionally as part of the up/start actions should switch to built-in
WaitForCommunicator which will inspect the machine states by default to
align with the expected state updating side effects that would be in
effect for any internal provider shipped with vagrant.

Closes: #948
Partial-Fix: #193
2021-05-20 13:36:23 +01:00
Darragh Bailey
981642afeb
Invert forward ssh port behaviour (#1289)
Multi machines environments will result in collisions until auto
correction is implemented. Therefore invert to keep the forwarding of
the default ssh port disabled by default initially until can handle the
port collisions detection and resolving.

Relates: #1012
2021-05-18 18:30:56 +01:00
Darragh Bailey
878b5ffe61
Ensure state is fully removed for destroy (#1288)
Completely remove state after a destroy, and ensure removal of a
non-existing domain also scrubs the machine folder clean.

Closes: #1132
2021-05-18 18:21:54 +01:00
Matthias Blümel
07391048af Enable forward ssh-port to host
Provides an option to disable the forwarding in case it causes issues.
However based on original PRs adding the forwarded behaviour, it does
not appear to be intentional to exclude it permanently.

Closes: #1011
Closes: #1012
2021-05-16 19:55:54 +01:00
Darragh Bailey
f0b6897095
Adjust forwarded ports test to include other network (#1287)
Ensure the forwarded ports tests filter out other types of network
entries.
2021-05-16 19:27:37 +01:00
Darragh Bailey
aa1c8bcb5f
Exclude LIBVIRT_DEFAULT_URI from impacting tests (#1283)
Some build environments may have this environment variable set to a
different default value than is expected by the tests. Have rspec delete
it from the environment before starting the test run to ensure that only
the tests that explicitly set it or other config values need expect
different behaviour.

Closes: #1255
2021-05-15 13:54:10 +00:00
Darragh Bailey
14b57df49d
Improve the development instructions (#1282)
Add some details to ensure correct execution of the rspec tests locally.

Closes: #1064
2021-05-15 14:47:05 +01:00
Darragh Bailey
5f09673c2a
Basic forward port tests and refactor out @env (#1281)
Adds some basic unit spec tests to validate the main behaviours around
the port forwarding to allow for subsequent behaviour changes.

Additionally removes the dependency on the instance variable @env for
internal functions to allow testing some of the internal functions
without needing to inject an instance variable that is not set on
initialization.

Includes a file contents matcher lifted from the cucumber/aruba project
on github, with some minor modifications instead of including the entire
gem.
2021-05-15 14:37:55 +01:00
Darragh Bailey
9d70d261b4
Corrections to two test testing tool (#1276)
Ensure the two disk test tool is used to ensure any tweaks to the format
made to the script are exercised.
2021-05-14 19:11:33 +01:00
Darragh Bailey
4edb9a6831
Ensure git describe works during tests (#1280)
Resolve the error `fatal: No names found, cannot describe anything`
response coming out of calling git-describe due to fetch depth of 1.
2021-05-14 17:22:51 +00:00
Darragh Bailey
63eece71c9
Enable no-response bot (#1279)
When issues need info and nothing is forthcoming for 30 days, have a bot
close the issue.
2021-05-14 14:22:45 +01:00
Pavel Valena
b7133d8f8f Since Ruby 3.0 rexml needs to be required
as it's no longer a default gem.
2021-05-12 21:38:43 +01:00
Darragh Bailey
9cc710bb4e
Merge pull request #1045 from zzambers/spinlocks-hyperv-feature
Add support for spinlocks hyperv feature
2021-05-12 21:03:24 +01:00
Zdenek Zambersky
3b1b17a5c9 Add support for spinlocks hyperv feature 2021-05-12 20:50:23 +02:00
Darragh Bailey
98ff2dfb51
Retrieve disk format and virtual size directly (#1274)
When uploading disks to libvirt storage it is unnecessary to require
that the virtual size or the format be provided as these can be
retrieved by calling qemu-img on the box files to retrieve the required
information.

Update the handle box image support to separate the handling of the two
different formats and remove the need to specify the additional settings
in the case of the V2 format for multi disk boxes.
2021-05-10 23:02:25 +01:00
Wong Hoi Sing Edison
70c4136836 Bugfix Additional Disks Storage File Ownership
For additional disk image created by
`lib/vagrant-libvirt/action/create_domain.rb`, it is now incorrectly
hard-coded with `group: storage_uid(env)`, so even QEMU process is
running with `root:libvirt` but file is still owned by `root:root`.

Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
2021-05-10 15:36:35 +01:00
TJ
4c2e59bc3f Allow Vagrantfile to set the CDROM image type
Although it is possible to attach additional images (disk or cdrom) the
cdrom functionality doesn't allow setting the :type - it defaults to
'raw' since vagrant-libvirt is assuming cdrom images are in ISO9660
format.

This assumption breaks down when using vagrant-mutate to convert a box
with multiple storage devices. A common situation is the Ubuntu boxes
built for VirtualBox that contain a cloud-init ISO9660 image with
user-data. vagrant-mutate converts the image to qcow* format (not
ISO9660) in order to not have to deal with what is inside.

This means the resulting libvirt domain needs to be told the type is
'qcow2' in order for the guest to see it as an ISO9660 image.

This patch adds the required option along with a sensible default.
2021-05-10 10:23:12 +01:00
Darragh Bailey
86cf4e08a7
Handle nil volumes when cd-rom attached (#1273)
When a cd-rom is attached as an additional storage, listing the volumes
can include a nil element. Make sure to check that the element is valid
before attempting to access the attribute.

Update the test to better match the observed behaviour.

Fixes: #1209, #1262
2021-05-08 17:27:04 +01:00
Darragh Bailey
fbf32889d7
Support force halt behaviour (#1270)
Vagrant subcommand halt accepts an argument -f that should result in
VMs being halted immediately instead of attempting a graceful shutdown.

Add support for this option and include tests to cover the rest of the
halt behaviour.

Fixes: #1265
2021-05-08 17:14:13 +01:00
Darragh Bailey
4830182ef8
Merge pull request #1271 from vagrant-libvirt/dev/allows_multi_disk_in_box
Adds support for a new multi disk box format and handling to upload the
multiple disks to the storage pool.

New format is:
{
  'disks': [
      {
          'name': 'disk1.img',
          'virtual_size': 10,
          'format': 'qcow2'
      },
      {
          'name': 'disk2.img',
          'virtual_size': 15,
          'format': 'qcow2'
      },
      {
          'name': 'disk3.img',
      }
  ],
  'provider': 'libvirt',
  'format': 'qcow2'
}

It is expected to remove format from being set at the top level when
using the new format, with the assuming that qcow2 should be the default
format, and other formats should be permitted to be specified as needed.

Includes tests for handling the box images and creation of domain
volumes. Additionally includes an integration test to ensure a box with
2 disks will work as expected.

Partially fixes: #602

Co-authored-by: Richard Turc <richard.turc@stormshield.eu>
2021-05-08 17:07:56 +01:00
Richard Turc
225237b125 Allow to use many disks in vagrant box for libvirt provider
Adds support for a new multi disk box format and handling to upload the
multiple disks to the storage pool.

New format is:
{
  'disks': [
    {
      'name': 'disk1.img',
      'virtual_size': 10,
      'format': 'qcow2'
    },
    {
      'name': 'disk2.img',
      'virtual_size': 15,
      'format': 'qcow2'
    },
    {
      'name': 'disk3.img',
    }
  ],
  'provider': 'libvirt',
  'format': 'qcow2'
}

It is expected to remove format from being set at the top level when
using the new format, with the assuming that qcow2 should be the default
format, and other formats should be permitted to be specified as needed.

Includes tests for handling the box images and creation of domain
volumes. Additionally includes an integration test to ensure a box with
2 disks will work as expected.

Partially fixes: #602
2021-05-08 17:04:10 +01:00
Darragh Bailey
6f608c54bf
Fix coveralls reporting (#1272)
Remove nested paths for checking out alternative versions of 
dependencies as this appears to break the github action upload of 
coverage.
2021-05-08 15:51:18 +00:00
Darragh Bailey
d764a308b4
Revert auto_config change in #1249 (#1253)
The #1249 introduce a change of behaviour on auto_config to skip if it
was any kind of false, where as the correct behaviour is to only skip if
explicitly set to false.
2021-04-19 12:34:20 +01:00