vagrant-libvirt 0.2.1 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +458 -50
- data/lib/vagrant-libvirt/action.rb +7 -1
- data/lib/vagrant-libvirt/action/clean_machine_folder.rb +30 -0
- data/lib/vagrant-libvirt/action/create_domain.rb +76 -23
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +57 -55
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +1 -3
- data/lib/vagrant-libvirt/action/create_networks.rb +11 -4
- data/lib/vagrant-libvirt/action/destroy_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/forward_ports.rb +37 -38
- data/lib/vagrant-libvirt/action/halt_domain.rb +25 -9
- data/lib/vagrant-libvirt/action/handle_box_image.rb +163 -72
- data/lib/vagrant-libvirt/action/is_running.rb +1 -3
- data/lib/vagrant-libvirt/action/is_suspended.rb +4 -4
- data/lib/vagrant-libvirt/action/package_domain.rb +10 -4
- data/lib/vagrant-libvirt/action/set_boot_order.rb +6 -2
- data/lib/vagrant-libvirt/action/start_domain.rb +86 -29
- data/lib/vagrant-libvirt/action/wait_till_up.rb +8 -52
- data/lib/vagrant-libvirt/cap/{mount_p9.rb → mount_9p.rb} +2 -2
- data/lib/vagrant-libvirt/cap/mount_virtiofs.rb +37 -0
- data/lib/vagrant-libvirt/cap/{synced_folder.rb → synced_folder_9p.rb} +4 -5
- data/lib/vagrant-libvirt/cap/synced_folder_virtiofs.rb +109 -0
- data/lib/vagrant-libvirt/config.rb +238 -44
- data/lib/vagrant-libvirt/driver.rb +49 -32
- data/lib/vagrant-libvirt/errors.rb +24 -1
- data/lib/vagrant-libvirt/plugin.rb +14 -5
- data/lib/vagrant-libvirt/provider.rb +2 -9
- data/lib/vagrant-libvirt/templates/domain.xml.erb +35 -10
- data/lib/vagrant-libvirt/templates/private_network.xml.erb +1 -1
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +5 -1
- data/lib/vagrant-libvirt/util.rb +1 -0
- data/lib/vagrant-libvirt/util/network_util.rb +21 -3
- data/lib/vagrant-libvirt/util/ui.rb +23 -0
- data/lib/vagrant-libvirt/version +1 -0
- data/lib/vagrant-libvirt/version.rb +72 -1
- data/locales/en.yml +12 -0
- data/spec/spec_helper.rb +37 -3
- data/spec/support/binding_proc.rb +24 -0
- data/spec/support/libvirt_context.rb +2 -0
- data/spec/support/matchers/have_file_content.rb +63 -0
- data/spec/support/sharedcontext.rb +5 -1
- data/spec/unit/action/clean_machine_folder_spec.rb +58 -0
- data/spec/unit/action/create_domain_spec.rb +170 -0
- data/spec/unit/action/create_domain_spec/additional_disks_domain.xml +54 -0
- data/spec/unit/action/create_domain_spec/default_domain.xml +49 -0
- data/spec/unit/action/create_domain_spec/default_system_storage_pool.xml +17 -0
- data/spec/unit/action/create_domain_spec/default_user_storage_pool.xml +17 -0
- data/spec/unit/action/create_domain_volume_spec.rb +102 -0
- data/spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml +21 -0
- data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml +21 -0
- data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml +21 -0
- data/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml +21 -0
- data/spec/unit/action/destroy_domain_spec.rb +1 -1
- data/spec/unit/action/forward_ports_spec.rb +202 -0
- data/spec/unit/action/halt_domain_spec.rb +90 -0
- data/spec/unit/action/handle_box_image_spec.rb +363 -0
- data/spec/unit/action/start_domain_spec.rb +231 -0
- data/spec/unit/action/start_domain_spec/clock_timer_rtc.xml +50 -0
- data/spec/unit/action/start_domain_spec/default.xml +48 -0
- data/spec/unit/action/start_domain_spec/default_added_tpm_path.xml +48 -0
- data/spec/unit/action/start_domain_spec/default_added_tpm_version.xml +48 -0
- data/spec/unit/action/wait_till_up_spec.rb +22 -21
- data/spec/unit/config_spec.rb +395 -127
- data/spec/unit/templates/domain_all_settings.xml +14 -3
- data/spec/unit/templates/domain_custom_cpu_model.xml +2 -1
- data/spec/unit/templates/domain_defaults.xml +2 -1
- data/spec/unit/templates/domain_spec.rb +100 -3
- data/spec/unit/templates/tpm/version_1.2.xml +54 -0
- data/spec/unit/templates/tpm/version_2.0.xml +53 -0
- metadata +107 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4af147b9b5fb6d00d46b0027da6314153012a8fe8c77e64ba0a497ccb46151fa
|
4
|
+
data.tar.gz: 052ea81b672906f4b2c2476c0f7e84f4f0e40f45fb00d70239a68f25c94311a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12662ab4dd96312b36cb5afa24d35b6558f247e53bbfb89903d748fb7c59e4cef2847c75d5025e8b8b39b92f5914b44647ff80e8aa3ac0e829f95648538540ee
|
7
|
+
data.tar.gz: fe1005190e1904f64fe60a4dddeadc867a7898c59b5762fa3db03d106b37091e1a5335a453c1b39728bb715603c1a18c1ea22d560a8da66fd7cb4c52e42fe8a0
|
data/README.md
CHANGED
@@ -21,6 +21,7 @@ can help a lot :-)
|
|
21
21
|
* [Using Docker based Installation](#using-docker-based-installation)
|
22
22
|
* [Installation](#installation)
|
23
23
|
* [Possible problems with plugin installation on Linux](#possible-problems-with-plugin-installation-on-linux)
|
24
|
+
* [Additional Notes for Fedora and Similar Linux Distributions](#additional-notes-for-fedora-and-similar-linux-distributions)
|
24
25
|
* [Vagrant Project Preparation](#vagrant-project-preparation)
|
25
26
|
* [Add Box](#add-box)
|
26
27
|
* [Create Vagrantfile](#create-vagrantfile)
|
@@ -48,18 +49,23 @@ can help a lot :-)
|
|
48
49
|
* [Watchdog device](#watchdog-device)
|
49
50
|
* [Smartcard device](#smartcard-device)
|
50
51
|
* [Hypervisor Features](#hypervisor-features)
|
52
|
+
* [Clock](#clock)
|
51
53
|
* [CPU features](#cpu-features)
|
52
54
|
* [Memory Backing](#memory-backing)
|
53
55
|
* [No box and PXE boot](#no-box-and-pxe-boot)
|
54
56
|
* [SSH Access To VM](#ssh-access-to-vm)
|
55
57
|
* [Forwarded Ports](#forwarded-ports)
|
58
|
+
* [Forwarding the ssh-port](#forwarding-the-ssh-port)
|
56
59
|
* [Synced Folders](#synced-folders)
|
57
60
|
* [QEMU Session Support](#qemu-session-support)
|
58
61
|
* [Customized Graphics](#customized-graphics)
|
59
62
|
* [TPM Devices](#tpm-devices)
|
63
|
+
* [Memory balloon](#memory-balloon)
|
60
64
|
* [Libvirt communication channels](#libvirt-communication-channels)
|
61
65
|
* [Custom command line arguments and environment variables](#custom-command-line-arguments-and-environment-variables)
|
62
|
-
* [Box
|
66
|
+
* [Box Formats](#box-formats)
|
67
|
+
* [Version 1](#version-1)
|
68
|
+
* [Version 2 (Experimental)](#version-2-experimental)
|
63
69
|
* [Create Box](#create-box)
|
64
70
|
* [Package Box from VM](#package-box-from-vm)
|
65
71
|
* [Troubleshooting VMs](#troubleshooting-vms)
|
@@ -80,7 +86,7 @@ can help a lot :-)
|
|
80
86
|
* SSH into domains.
|
81
87
|
* Setup hostname and network interfaces.
|
82
88
|
* Provision domains with any built-in Vagrant provisioner.
|
83
|
-
* Synced folder support via `rsync`, `nfs` or `
|
89
|
+
* Synced folder support via `rsync`, `nfs`, `9p` or `virtiofs`.
|
84
90
|
* Snapshots via [sahara](https://github.com/jedi4ever/sahara).
|
85
91
|
* Package caching via
|
86
92
|
[vagrant-cachier](http://fgrehm.viewdocs.io/vagrant-cachier/).
|
@@ -108,18 +114,40 @@ To get the image:
|
|
108
114
|
docker pull vagrantlibvirt/vagrant-libvirt:latest
|
109
115
|
```
|
110
116
|
|
117
|
+
Preparing the docker run, only once:
|
118
|
+
|
119
|
+
```bash
|
120
|
+
mkdir -p ~/.vagrant.d/{boxes,data,tmp}
|
121
|
+
```
|
122
|
+
|
111
123
|
Running the image:
|
112
124
|
```bash
|
113
|
-
docker run -it
|
125
|
+
docker run -it --rm \
|
114
126
|
-e LIBVIRT_DEFAULT_URI \
|
115
127
|
-v /var/run/libvirt/:/var/run/libvirt/ \
|
116
128
|
-v ~/.vagrant.d:/.vagrant.d \
|
117
129
|
-v $(pwd):$(pwd) \
|
118
130
|
-w $(pwd) \
|
131
|
+
--network host \
|
119
132
|
vagrantlibvirt/vagrant-libvirt:latest \
|
120
133
|
vagrant status
|
121
134
|
```
|
122
135
|
|
136
|
+
It's possible to define an alias in `~/.bashrc`, for example:
|
137
|
+
```bash
|
138
|
+
alias vagrant='
|
139
|
+
mkdir -p ~/.vagrant.d/{boxes,data,tmp}; \
|
140
|
+
docker run -it --rm \
|
141
|
+
-e LIBVIRT_DEFAULT_URI \
|
142
|
+
-v /var/run/libvirt/:/var/run/libvirt/ \
|
143
|
+
-v ~/.vagrant.d:/.vagrant.d \
|
144
|
+
-v $(pwd):$(pwd) \
|
145
|
+
-w $(pwd) \
|
146
|
+
--network host \
|
147
|
+
vagrantlibvirt/vagrant-libvirt:latest \
|
148
|
+
vagrant'
|
149
|
+
```
|
150
|
+
|
123
151
|
Note that if you are connecting to a remote system libvirt, you may omit the
|
124
152
|
`-v /var/run/libvirt/:/var/run/libvirt/` mount bind. Some distributions patch the local
|
125
153
|
vagrant environment to ensure vagrant-libvirt uses `qemu:///session`, which means you
|
@@ -231,6 +259,69 @@ If you have issues building ruby-libvirt, try the following:
|
|
231
259
|
```shell
|
232
260
|
CONFIGURE_ARGS='with-ldflags=-L/opt/vagrant/embedded/lib with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib' GEM_HOME=~/.vagrant.d/gems GEM_PATH=$GEM_HOME:/opt/vagrant/embedded/gems PATH=/opt/vagrant/embedded/bin:$PATH vagrant plugin install vagrant-libvirt
|
233
261
|
```
|
262
|
+
### Additional Notes for Fedora and Similar Linux Distributions
|
263
|
+
|
264
|
+
If you encounter the following load error when using the vagrant-libvirt plugin (note the required by libssh):
|
265
|
+
|
266
|
+
```shell
|
267
|
+
/opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': /opt/vagrant/embedded/lib64/libcrypto.so.1.1: version `OPENSSL_1_1_1b' not found (required by /lib64/libssh.so.4) - /home/xxx/.vagrant.d/gems/2.4.6/gems/ruby-libvirt-0.7.1/lib/_libvirt.so (LoadError)
|
268
|
+
```
|
269
|
+
then the following steps have been found to resolve the problem. Thanks to James Reynolds (see https://github.com/hashicorp/vagrant/issues/11020#issuecomment-540043472). The specific version of libssh will change over time so references to the rpm in the commands below will need to be adjusted accordingly.
|
270
|
+
|
271
|
+
```shell
|
272
|
+
# Fedora
|
273
|
+
dnf download --source libssh
|
274
|
+
|
275
|
+
# centos 8 stream, doesn't provide source RPMs, so you need to download like so
|
276
|
+
git clone https://git.centos.org/centos-git-common
|
277
|
+
# centos-git-common needs its tools in PATH
|
278
|
+
export PATH=$(readlink -f ./centos-git-common):$PATH
|
279
|
+
git clone https://git.centos.org/rpms/libssh
|
280
|
+
cd libssh
|
281
|
+
git checkout imports/c8s/libssh-0.9.4-1.el8
|
282
|
+
into_srpm.sh -d c8s
|
283
|
+
cd SRPMS
|
284
|
+
|
285
|
+
# common commands (make sure to adjust verison accordingly)
|
286
|
+
rpm2cpio libssh-0.9.0-5.fc30.src.rpm | cpio -imdV
|
287
|
+
tar xf libssh-0.9.0.tar.xz
|
288
|
+
mkdir build
|
289
|
+
cd build
|
290
|
+
cmake ../libssh-0.9.0 -DOPENSSL_ROOT_DIR=/opt/vagrant/embedded/
|
291
|
+
make
|
292
|
+
sudo cp lib/libssh* /opt/vagrant/embedded/lib64
|
293
|
+
```
|
294
|
+
|
295
|
+
If you encounter the following load error when using the vagrant-libvirt plugin (note the required by libk5crypto):
|
296
|
+
|
297
|
+
```shell
|
298
|
+
/opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': /usr/lib64/libk5crypto.so.3: undefined symbol: EVP_KDF_ctrl, version OPENSSL_1_1_1b - /home/rbelgrave/.vagrant.d/gems/2.4.9/gems/ruby-libvirt-0.7.1/lib/_libvirt.so (LoadError)
|
299
|
+
```
|
300
|
+
|
301
|
+
then the following steps have been found to resolve the problem. After the steps below are complete, then reinstall the vagrant-libvirt plugin without setting the `CONFIGURE_ARGS`. Thanks to Marco Bevc (see https://github.com/hashicorp/vagrant/issues/11020#issuecomment-625801983):
|
302
|
+
|
303
|
+
```shell
|
304
|
+
# Fedora
|
305
|
+
dnf download --source krb5-libs
|
306
|
+
|
307
|
+
# centos 8 stream, doesn't provide source RPMs, so you need to download like so
|
308
|
+
git clone https://git.centos.org/centos-git-common
|
309
|
+
# centos-git-common needs its tools in PATH
|
310
|
+
export PATH=$(readlink -f ./centos-git-common):$PATH
|
311
|
+
git clone https://git.centos.org/rpms/krb5
|
312
|
+
cd krb5
|
313
|
+
git checkout imports/c8s/krb5-1.18.2-8.el8
|
314
|
+
into_srpm.sh -d c8s
|
315
|
+
cd SRPMS
|
316
|
+
|
317
|
+
# common commands (make sure to adjust verison accordingly)
|
318
|
+
rpm2cpio krb5-1.18-1.fc32.src.rpm | cpio -imdV
|
319
|
+
tar xf krb5-1.18.tar.gz
|
320
|
+
cd krb5-1.18/src
|
321
|
+
./configure
|
322
|
+
make
|
323
|
+
sudo cp -P lib/crypto/libk5crypto.* /opt/vagrant/embedded/lib64/
|
324
|
+
```
|
234
325
|
|
235
326
|
## Vagrant Project Preparation
|
236
327
|
|
@@ -312,10 +403,25 @@ URI](http://libvirt.org/uri.html):
|
|
312
403
|
Default is `$HOME/.ssh/id_rsa`. Prepends `$HOME/.ssh/` if no directory
|
313
404
|
* `socket` - Path to the Libvirt unix socket (e.g.
|
314
405
|
`/var/run/libvirt/libvirt-sock`)
|
406
|
+
* `proxy_command` - For advanced usage. When connecting to remote libvirt
|
407
|
+
instances, if the default constructed proxy\_command which uses `-W %h:%p`
|
408
|
+
does not work, set this as needed. It performs interpolation using `{key}`
|
409
|
+
and supports only `{host}`, `{username}`, and `{id_ssh_key_file}`. This is
|
410
|
+
to try and avoid issues with escaping `%` and `$` which might be necessary
|
411
|
+
to the ssh command itself. e.g.:
|
412
|
+
`libvirt.proxy_command = "ssh {host} -l {username} -i {id_ssh_key_file} nc %h %p"`
|
315
413
|
* `uri` - For advanced usage. Directly specifies what Libvirt connection URI
|
316
414
|
vagrant-libvirt should use. Overrides all other connection configuration
|
317
415
|
options
|
318
416
|
|
417
|
+
In the event that none of these are set (excluding the `driver` option) the
|
418
|
+
provider will attempt to retrieve the uri from the environment variable
|
419
|
+
`LIBVIRT_DEFAULT_URI` similar to how virsh works. If any of them are set, it
|
420
|
+
will ignore the environment variable. The reason the driver option is ignored
|
421
|
+
is that it is not uncommon for this to be explicitly set on the box itself
|
422
|
+
and there is no easily to determine whether it is being set by the user or
|
423
|
+
the box packager.
|
424
|
+
|
319
425
|
Connection-independent options:
|
320
426
|
|
321
427
|
* `storage_pool_name` - Libvirt storage pool name, where box image and instance
|
@@ -347,6 +453,14 @@ end
|
|
347
453
|
set, which should be fine for paravirtualized guests, but some fully
|
348
454
|
virtualized guests may require hda. NOTE: this option also applies only to
|
349
455
|
disks associated with a box image.
|
456
|
+
* `disk_driver` - Extra options for the main disk driver ([see Libvirt documentation](http://libvirt.org/formatdomain.html#elementsDisks)).
|
457
|
+
NOTE: this option also applies only to disks associated with a box image. In all cases, the value `nil` can be used to force the hypervisor default behaviour (e.g. to override settings defined in top-level Vagrantfiles). Supported options include:
|
458
|
+
* `:cache` - Controls the cache mechanism. Possible values are "default", "none", "writethrough", "writeback", "directsync" and "unsafe".
|
459
|
+
* `:io` - Controls specific policies on I/O. Possible values are "threads" and "native".
|
460
|
+
* `:copy_on_read` - Controls whether to copy read backing file into the image file. The value can be either "on" or "off".
|
461
|
+
* `:discard` - Controls whether discard requests (also known as "trim" or "unmap") are ignored or passed to the filesystem. Possible values are "unmap" or "ignore".
|
462
|
+
Note: for discard to work, you will likely also need to set `disk_bus = 'scsi'`
|
463
|
+
* `:detect_zeroes` - Controls whether to detect zero write requests. The value can be "off", "on" or "unmap".
|
350
464
|
* `nic_model_type` - parameter specifies the model of the network adapter when
|
351
465
|
you create a domain value by default virtio KVM believe possible values, see
|
352
466
|
the [documentation for
|
@@ -392,10 +506,6 @@ end
|
|
392
506
|
]
|
393
507
|
```
|
394
508
|
* `loader` - Sets path to custom UEFI loader.
|
395
|
-
* `volume_cache` - Controls the cache mechanism. Possible values are "default",
|
396
|
-
"none", "writethrough", "writeback", "directsync" and "unsafe". [See
|
397
|
-
driver->cache in Libvirt
|
398
|
-
documentation](http://libvirt.org/formatdomain.html#elementsDisks).
|
399
509
|
* `kernel` - To launch the guest with a kernel residing on host filesystems.
|
400
510
|
Equivalent to qemu `-kernel`.
|
401
511
|
* `initrd` - To specify the initramfs/initrd to use for the guest. Equivalent
|
@@ -467,6 +577,7 @@ end
|
|
467
577
|
* `tpm_model` - The model of the TPM to which you wish to connect.
|
468
578
|
* `tpm_type` - The type of TPM device to which you are connecting.
|
469
579
|
* `tpm_path` - The path to the TPM device on the host system.
|
580
|
+
* `tpm_version` - The TPM version to use.
|
470
581
|
* `dtb` - The device tree blob file, mostly used for non-x86 platforms. In case
|
471
582
|
the device tree isn't added in-line to the kernel, it can be manually
|
472
583
|
specified here.
|
@@ -495,7 +606,7 @@ Vagrant.configure("2") do |config|
|
|
495
606
|
domain.memory = 2048
|
496
607
|
domain.cpus = 2
|
497
608
|
domain.nested = true
|
498
|
-
domain.
|
609
|
+
domain.disk_driver :cache => 'none'
|
499
610
|
end
|
500
611
|
end
|
501
612
|
|
@@ -542,6 +653,7 @@ defined domain:
|
|
542
653
|
* `tpm_model` - Updated
|
543
654
|
* `tpm_type` - Updated
|
544
655
|
* `tpm_path` - Updated
|
656
|
+
* `tpm_version` - Updated
|
545
657
|
|
546
658
|
## Networks
|
547
659
|
|
@@ -671,8 +783,8 @@ starts with `libvirt__` string. Here is a list of those options:
|
|
671
783
|
only when dhcp is enabled.By default is the same host that runs the DHCP
|
672
784
|
server.
|
673
785
|
* `:libvirt__adapter` - Number specifiyng sequence number of interface.
|
674
|
-
* `:libvirt__forward_mode` - Specify one of `veryisolated`, `none`, `nat`
|
675
|
-
`route` options. This option is used only when creating new network. Mode
|
786
|
+
* `:libvirt__forward_mode` - Specify one of `veryisolated`, `none`, `open`, `nat`
|
787
|
+
or `route` options. This option is used only when creating new network. Mode
|
676
788
|
`none` will create isolated network without NATing or routing outside. You
|
677
789
|
will want to use NATed forwarding typically to reach networks outside of
|
678
790
|
hypervisor. Routed forwarding is typically useful to reach other networks
|
@@ -751,6 +863,7 @@ virtual network.
|
|
751
863
|
* `:portgroup` - Name of Libvirt portgroup to connect to.
|
752
864
|
* `:ovs` - Support to connect to an Open vSwitch bridge device. Default is
|
753
865
|
'false'.
|
866
|
+
* :ovs_interfaceid - Add Open vSwitch 'interfaceid' parameter.
|
754
867
|
* `:trust_guest_rx_filters` - Support trustGuestRxFilters attribute. Details
|
755
868
|
are listed [here](http://www.libvirt.org/formatdomain.html#elementsNICSDirect).
|
756
869
|
Default is 'false'.
|
@@ -769,8 +882,8 @@ used by this network are configurable at the provider level.
|
|
769
882
|
connected. Must include the address and subnet mask. If not specified the
|
770
883
|
default is '192.168.121.0/24'.
|
771
884
|
* `management_network_mode` - Network mode for the Libvirt management network.
|
772
|
-
Specify one of veryisolated, none, nat or route options. Further
|
773
|
-
under [Private Networks](#private-network-options)
|
885
|
+
Specify one of veryisolated, none, open, nat or route options. Further
|
886
|
+
documented under [Private Networks](#private-network-options)
|
774
887
|
* `management_network_guest_ipv6` - Enable or disable guest-to-guest IPv6
|
775
888
|
communication. See
|
776
889
|
[here](https://libvirt.org/formatnetwork.html#examplesPrivate6), and
|
@@ -782,6 +895,8 @@ used by this network are configurable at the provider level.
|
|
782
895
|
* `management_network_pci_slot` - The slot of the PCI device.
|
783
896
|
* `management_network_mac` - MAC address of management network interface.
|
784
897
|
* `management_network_domain` - Domain name assigned to the management network.
|
898
|
+
* `management_network_mtu` - MTU size of management network. If not specified,
|
899
|
+
the Libvirt default (1500) will be used.
|
785
900
|
|
786
901
|
You may wonder how vagrant-libvirt knows the IP address a VM received. Libvirt
|
787
902
|
doesn't provide a standard way to find out the IP address of a running domain.
|
@@ -803,11 +918,6 @@ It has a number of options:
|
|
803
918
|
* `size` - Size of the disk image. If unspecified, defaults to 10G.
|
804
919
|
* `type` - Type of disk image to create. Defaults to *qcow2*.
|
805
920
|
* `bus` - Type of bus to connect device to. Defaults to *virtio*.
|
806
|
-
* `cache` - Cache mode to use, e.g. `none`, `writeback`, `writethrough` (see
|
807
|
-
the [libvirt documentation for possible
|
808
|
-
values](http://libvirt.org/formatdomain.html#elementsDisks) or
|
809
|
-
[here](https://www.suse.com/documentation/sles11/book_kvm/data/sect1_chapter_book_kvm.html)
|
810
|
-
for a fuller explanation). Defaults to *default*.
|
811
921
|
* `allow_existing` - Set to true if you want to allow the VM to use a
|
812
922
|
pre-existing disk. If the disk doesn't exist it will be created.
|
813
923
|
Disks with this option set to true need to be removed manually.
|
@@ -815,13 +925,25 @@ It has a number of options:
|
|
815
925
|
* `serial` - Serial number of the disk device.
|
816
926
|
* `wwn` - WWN number of the disk device.
|
817
927
|
|
928
|
+
The following disk performance options can also be configured
|
929
|
+
(see the [libvirt documentation for possible values](http://libvirt.org/formatdomain.html#elementsDisks)
|
930
|
+
or [here](https://www.suse.com/documentation/sles11/book_kvm/data/sect1_chapter_book_kvm.html) for a fuller explanation).
|
931
|
+
In all cases, the options use the hypervisor default if not specified, or if set to `nil`.
|
932
|
+
|
933
|
+
* `cache` - Cache mode to use. Value may be `default`, `none`, `writeback`, `writethrough`, `directsync` or `unsafe`.
|
934
|
+
* `io` - Controls specific policies on I/O. Value may be `threads` or `native`.
|
935
|
+
* `copy_on_read` - Controls whether to copy read backing file into the image file. Value may be `on` or `off`.
|
936
|
+
* `discard` - Controls whether discard requests (also known as "trim" or "unmap") are ignored or passed to the filesystem. Value may be `unmap` or `ignore`.
|
937
|
+
Note: for discard to work, you will likely also need to set `:bus => 'scsi'`
|
938
|
+
* `detect_zeroes` - Controls whether to detect zero write requests. Value may be `off`, `on` or `unmap`.
|
939
|
+
|
818
940
|
The following example creates two additional disks.
|
819
941
|
|
820
942
|
```ruby
|
821
943
|
Vagrant.configure("2") do |config|
|
822
944
|
config.vm.provider :libvirt do |libvirt|
|
823
945
|
libvirt.storage :file, :size => '20G'
|
824
|
-
libvirt.storage :file, :size => '40G', :type => 'raw'
|
946
|
+
libvirt.storage :file, :size => '40G', :bus => 'scsi', :type => 'raw', :discard => 'unmap', :detect_zeroes => 'on'
|
825
947
|
end
|
826
948
|
end
|
827
949
|
```
|
@@ -1139,6 +1261,29 @@ Vagrant.configure("2") do |config|
|
|
1139
1261
|
libvirt.hyperv_feature :name => 'relaxed', :state => 'on'
|
1140
1262
|
# Enable virtual APIC
|
1141
1263
|
libvirt.hyperv_feature :name => 'vapic', :state => 'on'
|
1264
|
+
# Enable spinlocks (requires retries to be specified)
|
1265
|
+
libvirt.hyperv_feature :name => 'spinlocks', :state => 'on', :retries => '8191'
|
1266
|
+
end
|
1267
|
+
end
|
1268
|
+
```
|
1269
|
+
|
1270
|
+
## Clock
|
1271
|
+
|
1272
|
+
Clock offset can be specified via `libvirt.clock_offset`. (Default is utc)
|
1273
|
+
|
1274
|
+
Additionally timers can be specified via `libvirt.clock_timer`.
|
1275
|
+
Available options for timers are: name, track, tickpolicy, frequency, mode, present
|
1276
|
+
|
1277
|
+
```ruby
|
1278
|
+
Vagrant.configure("2") do |config|
|
1279
|
+
config.vm.provider :libvirt do |libvirt|
|
1280
|
+
# Set clock offset to localtime
|
1281
|
+
libvirt.clock_offset = 'localtime'
|
1282
|
+
# Timers ...
|
1283
|
+
libvirt.clock_timer :name => 'rtc', :tickpolicy => 'catchup'
|
1284
|
+
libvirt.clock_timer :name => 'pit', :tickpolicy => 'delay'
|
1285
|
+
libvirt.clock_timer :name => 'hpet', :present => 'no'
|
1286
|
+
libvirt.clock_timer :name => 'hypervclock', :present => 'yes'
|
1142
1287
|
end
|
1143
1288
|
end
|
1144
1289
|
```
|
@@ -1244,6 +1389,24 @@ Name of network "foreman_managed" is key for define boot order
|
|
1244
1389
|
end
|
1245
1390
|
```
|
1246
1391
|
|
1392
|
+
An example VM that is PXE booted from the `br1` device (which must already be configured in the host machine), and if that fails, is booted from the disk:
|
1393
|
+
|
1394
|
+
```ruby
|
1395
|
+
Vagrant.configure("2") do |config|
|
1396
|
+
config.vm.define :pxeclient do |pxeclient|
|
1397
|
+
pxeclient.vm.network :public_network,
|
1398
|
+
dev: 'br1',
|
1399
|
+
auto_config: false
|
1400
|
+
pxeclient.vm.provider :libvirt do |domain|
|
1401
|
+
boot_network = {'dev' => 'br1'}
|
1402
|
+
domain.storage :file, :size => '100G'
|
1403
|
+
domain.boot boot_network
|
1404
|
+
domain.boot 'hd'
|
1405
|
+
end
|
1406
|
+
end
|
1407
|
+
end
|
1408
|
+
```
|
1409
|
+
|
1247
1410
|
## SSH Access To VM
|
1248
1411
|
|
1249
1412
|
vagrant-libvirt supports vagrant's [standard ssh
|
@@ -1274,40 +1437,157 @@ Default is `eth0`.
|
|
1274
1437
|
|
1275
1438
|
`config.vm.network :forwarded_port, guest: 80, host: 2000, host_ip: "0.0.0.0"`
|
1276
1439
|
|
1440
|
+
### Forwarding the ssh-port
|
1441
|
+
|
1442
|
+
Vagrant-libvirt now supports forwarding the standard ssh-port on port 2222 from
|
1443
|
+
the localhost to allow for consistent provisioning steps/ports to be used when
|
1444
|
+
defining across multiple providers.
|
1445
|
+
|
1446
|
+
To enable, set the following:
|
1447
|
+
```ruby
|
1448
|
+
Vagrant.configure("2") do |config|
|
1449
|
+
config.vm.provider :libvirt do |libvirt|
|
1450
|
+
# Enable forwarding of forwarded_port with id 'ssh'.
|
1451
|
+
libvirt.forward_ssh_port = true
|
1452
|
+
end
|
1453
|
+
end
|
1454
|
+
```
|
1455
|
+
|
1456
|
+
Previously by default libvirt skipped the forwarding of the ssh-port because
|
1457
|
+
you can access the machine directly. In the future it is expected that this
|
1458
|
+
will be enabled by default once autocorrect support is added to handle port
|
1459
|
+
collisions for multi machine environments gracefully.
|
1460
|
+
|
1277
1461
|
## Synced Folders
|
1278
1462
|
|
1279
|
-
Vagrant automatically syncs the project folder on the host to `/vagrant` in
|
1280
|
-
additional synced folders.
|
1463
|
+
Vagrant automatically syncs the project folder on the host to `/vagrant` in
|
1464
|
+
the guest. You can also configure additional synced folders.
|
1281
1465
|
|
1282
|
-
|
1283
|
-
|
1466
|
+
**SECURITY NOTE:** for remote Libvirt, nfs synced folders requires a bridged
|
1467
|
+
public network interface and you must connect to Libvirt via ssh.
|
1284
1468
|
|
1285
|
-
|
1286
|
-
it an setting the type, e.g.
|
1469
|
+
**NFS**
|
1287
1470
|
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1471
|
+
`vagrant-libvirt` supports
|
1472
|
+
[NFS](https://www.vagrantup.com/docs/synced-folders/nfs) as default with
|
1473
|
+
bidirectional synced folders.
|
1291
1474
|
|
1292
|
-
|
1475
|
+
Example with NFS:
|
1293
1476
|
|
1294
|
-
```
|
1295
|
-
|
1477
|
+
``` ruby
|
1478
|
+
Vagrant.configure("2") do |config|
|
1479
|
+
config.vm.synced_folder "./", "/vagrant"
|
1480
|
+
end
|
1296
1481
|
```
|
1297
1482
|
|
1298
|
-
|
1483
|
+
**RSync**
|
1299
1484
|
|
1300
|
-
|
1301
|
-
|
1485
|
+
`vagrant-libvirt` supports
|
1486
|
+
[rsync](https://www.vagrantup.com/docs/synced-folders/rsync) with
|
1487
|
+
unidirectional synced folders.
|
1488
|
+
|
1489
|
+
Example with rsync:
|
1490
|
+
|
1491
|
+
``` ruby
|
1492
|
+
Vagrant.configure("2") do |config|
|
1493
|
+
config.vm.synced_folder "./", "/vagrant", type: "rsync"
|
1494
|
+
end
|
1302
1495
|
```
|
1303
1496
|
|
1497
|
+
**9P**
|
1498
|
+
|
1499
|
+
`vagrant-libvirt` supports [VirtFS](http://www.linux-kvm.org/page/VirtFS) ([9p
|
1500
|
+
or Plan 9](https://en.wikipedia.org/wiki/9P_\(protocol\))) with bidirectional
|
1501
|
+
synced folders.
|
1502
|
+
|
1503
|
+
Difference between NFS and 9p is explained
|
1504
|
+
[here](https://unix.stackexchange.com/questions/240281/virtfs-plan-9-vs-nfs-as-tool-for-share-folder-for-virtual-machine).
|
1505
|
+
|
1304
1506
|
For 9p shares, a `mount: false` option allows to define synced folders without
|
1305
1507
|
mounting them at boot.
|
1306
1508
|
|
1307
|
-
|
1509
|
+
Example for `accessmode: "squash"` with 9p:
|
1308
1510
|
|
1309
|
-
|
1310
|
-
|
1511
|
+
``` ruby
|
1512
|
+
Vagrant.configure("2") do |config|
|
1513
|
+
config.vm.synced_folder "./", "/vagrant", type: "9p", disabled: false, accessmode: "squash", owner: "1000"
|
1514
|
+
end
|
1515
|
+
```
|
1516
|
+
|
1517
|
+
Example for `accessmode: "mapped"` with 9p:
|
1518
|
+
|
1519
|
+
``` ruby
|
1520
|
+
Vagrant.configure("2") do |config|
|
1521
|
+
config.vm.synced_folder "./", "/vagrant", type: "9p", disabled: false, accessmode: "mapped", mount: false
|
1522
|
+
end
|
1523
|
+
```
|
1524
|
+
|
1525
|
+
Further documentation on using 9p can be found in [kernel
|
1526
|
+
docs](https://www.kernel.org/doc/Documentation/filesystems/9p.txt) and in
|
1527
|
+
[QEMU
|
1528
|
+
wiki](https://wiki.qemu.org/Documentation/9psetup#Starting_the_Guest_directly).
|
1529
|
+
|
1530
|
+
Please do note that 9p depends on support in the guest and not all distros
|
1531
|
+
come with the 9p module by default.
|
1532
|
+
|
1533
|
+
**Virtio-fs**
|
1534
|
+
|
1535
|
+
`vagrant-libvirt` supports [Virtio-fs](https://virtio-fs.gitlab.io/) with
|
1536
|
+
bidirectional synced folders.
|
1537
|
+
|
1538
|
+
For virtiofs shares, a `mount: false` option allows to define synced folders
|
1539
|
+
without mounting them at boot.
|
1540
|
+
|
1541
|
+
So far, passthrough is the only supported access mode and it requires running
|
1542
|
+
the virtiofsd daemon as root.
|
1543
|
+
|
1544
|
+
QEMU needs to allocate the backing memory for all the guest RAM as shared
|
1545
|
+
memory, e.g. [Use file-backed
|
1546
|
+
memory](https://libvirt.org/kbase/virtiofs.html#host-setup) by enable
|
1547
|
+
`memory_backing_dir` option in `/etc/libvirt/qemu.conf`:
|
1548
|
+
|
1549
|
+
``` shell
|
1550
|
+
memory_backing_dir = "/dev/shm"
|
1551
|
+
```
|
1552
|
+
|
1553
|
+
Example for Libvirt \>= 6.2.0 (e.g. Ubuntu 20.10 with Linux 5.8.0 + QEMU 5.0 +
|
1554
|
+
Libvirt 6.6.0, i.e. NUMA nodes required) with virtiofs:
|
1555
|
+
|
1556
|
+
``` ruby
|
1557
|
+
Vagrant.configure("2") do |config|
|
1558
|
+
config.vm.provider :libvirt do |libvirt|
|
1559
|
+
libvirt.cpus = 2
|
1560
|
+
libvirt.numa_nodes = [{ :cpus => "0-1", :memory => 8192, :memAccess => "shared" }]
|
1561
|
+
libvirt.memorybacking :access, :mode => "shared"
|
1562
|
+
end
|
1563
|
+
config.vm.synced_folder "./", "/vagrant", type: "virtiofs"
|
1564
|
+
end
|
1565
|
+
```
|
1566
|
+
|
1567
|
+
Example for Libvirt \>= 6.9.0 (e.g. Ubuntu 21.04 with Linux 5.11.0 + QEMU 5.2 +
|
1568
|
+
Libvirt 7.0.0, or Ubuntu 20.04 + [PPA
|
1569
|
+
enabled](https://launchpad.net/~savoury1/+archive/ubuntu/virtualisation)) with
|
1570
|
+
virtiofs:
|
1571
|
+
|
1572
|
+
``` ruby
|
1573
|
+
Vagrant.configure("2") do |config|
|
1574
|
+
config.vm.provider :libvirt do |libvirt|
|
1575
|
+
libvirt.cpus = 2
|
1576
|
+
libvirt.memory = 8192
|
1577
|
+
libvirt.memorybacking :access, :mode => "shared"
|
1578
|
+
end
|
1579
|
+
config.vm.synced_folder "./", "/vagrant", type: "virtiofs"
|
1580
|
+
end
|
1581
|
+
```
|
1582
|
+
|
1583
|
+
Further documentation on using virtiofs can be found in [official
|
1584
|
+
HowTo](https://virtio-fs.gitlab.io/index.html#howto) and in [Libvirt
|
1585
|
+
KB](https://libvirt.org/kbase/virtiofs.html).
|
1586
|
+
|
1587
|
+
Please do note that virtiofs depends on:
|
1588
|
+
|
1589
|
+
- Host: Linux \>= 5.4, QEMU \>= 4.2 and Libvirt \>= 6.2 (e.g. Ubuntu 20.10)
|
1590
|
+
- Guest: Linux \>= 5.4 (e.g. Ubuntu 20.04)
|
1311
1591
|
|
1312
1592
|
## QEMU Session Support
|
1313
1593
|
|
@@ -1370,13 +1650,14 @@ Modern versions of Libvirt support connecting to TPM devices on the host
|
|
1370
1650
|
system. This allows you to enable Trusted Boot Extensions, among other
|
1371
1651
|
features, on your guest VMs.
|
1372
1652
|
|
1373
|
-
|
1374
|
-
configuration. However, advanced usage,
|
1375
|
-
TPM, may require modifying the
|
1653
|
+
To passthrough a hardware TPM, you will generally only need to modify the
|
1654
|
+
`tpm_path` variable in your guest configuration. However, advanced usage,
|
1655
|
+
such as the application of a Software TPM, may require modifying the
|
1656
|
+
`tpm_model`, `tpm_type` and `tpm_version` variables.
|
1376
1657
|
|
1377
|
-
The TPM options will only be used if you specify a TPM path
|
1378
|
-
any TPM options without specifying a path
|
1379
|
-
ignored.
|
1658
|
+
The TPM options will only be used if you specify a TPM path or version.
|
1659
|
+
Declarations of any TPM options without specifying a path or version will
|
1660
|
+
result in those options being ignored.
|
1380
1661
|
|
1381
1662
|
Here is an example of using the TPM options:
|
1382
1663
|
|
@@ -1390,6 +1671,41 @@ Vagrant.configure("2") do |config|
|
|
1390
1671
|
end
|
1391
1672
|
```
|
1392
1673
|
|
1674
|
+
It's also possible for Libvirt to start an emulated TPM device on the host.
|
1675
|
+
Requires `swtpm` and `swtpm-tools`
|
1676
|
+
|
1677
|
+
```ruby
|
1678
|
+
Vagrant.configure("2") do |config|
|
1679
|
+
config.vm.provider :libvirt do |libvirt|
|
1680
|
+
libvirt.tpm_model = "tpm-crb"
|
1681
|
+
libvirt.tpm_type = "emulator"
|
1682
|
+
libvirt.tpm_version = "2.0"
|
1683
|
+
end
|
1684
|
+
end
|
1685
|
+
```
|
1686
|
+
|
1687
|
+
## Memory balloon
|
1688
|
+
|
1689
|
+
The configuration of the memory balloon device can be overridden. By default,
|
1690
|
+
libvirt will automatically attach a memory balloon; this behavior is preserved
|
1691
|
+
by not configuring any memballoon-related options. The memory balloon can be
|
1692
|
+
explicitly disabled by setting `memballoon_enabled` to `false`. Setting
|
1693
|
+
`memballoon_enabled` to `true` will allow additional configuration of
|
1694
|
+
memballoon-related options.
|
1695
|
+
|
1696
|
+
Here is an example of using the memballoon options:
|
1697
|
+
|
1698
|
+
```ruby
|
1699
|
+
Vagrant.configure("2") do |config|
|
1700
|
+
config.vm.provider :libvirt do |libvirt|
|
1701
|
+
libvirt.memballoon_enabled = true
|
1702
|
+
libvirt.memballoon_model = 'virtio'
|
1703
|
+
libvirt.memballoon_pci_bus = '0x00'
|
1704
|
+
libvirt.memballoon_pci_slot = '0x0f'
|
1705
|
+
end
|
1706
|
+
end
|
1707
|
+
```
|
1708
|
+
|
1393
1709
|
## Libvirt communication channels
|
1394
1710
|
|
1395
1711
|
For certain functionality to be available within a guest, a private
|
@@ -1478,7 +1794,11 @@ Vagrant.configure("2") do |config|
|
|
1478
1794
|
end
|
1479
1795
|
```
|
1480
1796
|
|
1481
|
-
## Box
|
1797
|
+
## Box Formats
|
1798
|
+
|
1799
|
+
### Version 1
|
1800
|
+
|
1801
|
+
This is the original format that most boxes currently use.
|
1482
1802
|
|
1483
1803
|
You can view an example box in the
|
1484
1804
|
[`example_box/directory`](https://github.com/vagrant-libvirt/vagrant-libvirt/tree/master/example_box).
|
@@ -1492,8 +1812,64 @@ The box is a tarball containing:
|
|
1492
1812
|
* `Vagrantfile` that does default settings for the provider-specific
|
1493
1813
|
configuration for this provider
|
1494
1814
|
|
1815
|
+
|
1816
|
+
### Version 2 (Experimental)
|
1817
|
+
|
1818
|
+
Due to the limitation of only being able to handle a single disk with the version 1 format, a new
|
1819
|
+
format was added to support boxes that need to specify multiple disks. This is still currently
|
1820
|
+
experimental and as such support for packaging has yet to be added. There is a script in the tools
|
1821
|
+
folder (tools/create_box_with_two_disks.sh) that should provide a guideline on how to create such
|
1822
|
+
a box for those that wish to experiment and provide early feedback.
|
1823
|
+
|
1824
|
+
At it's most basic, it expects an array of disks to allow a specific order to be presented. Disks
|
1825
|
+
will be attached in this order and as such assume device names base on this within the VM. The
|
1826
|
+
'path' attribute is required, and is expected to be relative to the base of the box. This should
|
1827
|
+
allow placing the disk images within a nested directory within the box if it useful for those
|
1828
|
+
with a larger number of disks. The name allows overriding the target volume name that will be
|
1829
|
+
used in the libvirt storage pool. Note that vagrant-libvirt will still prefix the volume name
|
1830
|
+
with `#{box_name}_vagrant_box_image_#{box_version}_` to avoid accidental clashes with other boxes.
|
1831
|
+
|
1832
|
+
Format and virtual size need no longer be specified as they are now retrieved directly from the
|
1833
|
+
provided image using `qemu-img info ...`.
|
1834
|
+
|
1835
|
+
Example format:
|
1836
|
+
```json
|
1837
|
+
{
|
1838
|
+
'disks': [
|
1839
|
+
{
|
1840
|
+
'path': 'disk1.img'
|
1841
|
+
},
|
1842
|
+
{
|
1843
|
+
'path': 'disk2.img',
|
1844
|
+
'name': 'secondary_disk'
|
1845
|
+
},
|
1846
|
+
{
|
1847
|
+
'path': 'disk3.img'
|
1848
|
+
}
|
1849
|
+
],
|
1850
|
+
'provider': 'libvirt'
|
1851
|
+
}
|
1852
|
+
```
|
1853
|
+
|
1495
1854
|
## Create Box
|
1496
1855
|
|
1856
|
+
If creating a box from a modified vagrant-libvirt machine, ensure that
|
1857
|
+
you have set the `config.ssh.insert_key = false` in the original Vagrantfile
|
1858
|
+
as otherwise Vagrant will replace the default connection key-pair that is
|
1859
|
+
required on first boot with one specific to the machine and prevent
|
1860
|
+
the default key from working on the exported result.
|
1861
|
+
```ruby
|
1862
|
+
Vagrant.configure("2") do |config|
|
1863
|
+
# this setting is only recommended if planning to export the
|
1864
|
+
# resulting machine
|
1865
|
+
config.ssh.insert_key = false
|
1866
|
+
|
1867
|
+
config.vm.define :test_vm do |test_vm|
|
1868
|
+
test_vm.vm.box = "fedora/32-cloud-base"
|
1869
|
+
end
|
1870
|
+
end
|
1871
|
+
```
|
1872
|
+
|
1497
1873
|
To create a vagrant-libvirt box from a qcow2 image, run `create_box.sh`
|
1498
1874
|
(located in the tools directory):
|
1499
1875
|
|
@@ -1591,17 +1967,49 @@ $ bundle install
|
|
1591
1967
|
Once you have the dependencies, verify the unit tests pass with `rspec`:
|
1592
1968
|
|
1593
1969
|
```shell
|
1594
|
-
$
|
1970
|
+
$ export VAGRANT_HOME=$(mktemp -d)
|
1971
|
+
$ bundle exec rspec --fail-fast --color --format documentation
|
1972
|
+
```
|
1973
|
+
|
1974
|
+
If those pass, you're ready to start developing the plugin.
|
1975
|
+
|
1976
|
+
Setting `VAGRANT_HOME` is to avoid issues with conflicting with other
|
1977
|
+
plugins/gems or data already present under `~/.vagrant.d`.
|
1978
|
+
|
1979
|
+
Additionally if you wish to test against a specific version of vagrant you
|
1980
|
+
can control the version using the following before running the tests:
|
1981
|
+
|
1982
|
+
```shell
|
1983
|
+
$ export VAGRANT_VERSION=v2.2.14
|
1595
1984
|
```
|
1596
1985
|
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1986
|
+
**Note** rvm is used by the maintainers to help provide an environment to test
|
1987
|
+
against multiple ruby versions that align with the ones used by vagrant for
|
1988
|
+
their embedded ruby depending on the release. You can see what version is used
|
1989
|
+
by looking at the current [unit tests](.github/workflows/unit-tests.yml)
|
1990
|
+
workflow.
|
1991
|
+
|
1992
|
+
You can test the plugin without installing it into your Vagrant environment by
|
1993
|
+
just creating a `Vagrantfile` in the top level of this directory (it is
|
1994
|
+
gitignored) that uses it. You can add the following line to your Vagrantfile
|
1995
|
+
while in development to ensure vagrant checks that the plugin is installed:
|
1602
1996
|
|
1603
1997
|
```ruby
|
1604
|
-
Vagrant.
|
1998
|
+
Vagrant.configure("2") do |config|
|
1999
|
+
config.vagrant.plugins = "vagrant-libvirt"
|
2000
|
+
end
|
2001
|
+
```
|
2002
|
+
Or add the following to the top of the file to ensure that any required plugins
|
2003
|
+
are installed globally:
|
2004
|
+
```ruby
|
2005
|
+
REQUIRED_PLUGINS = %w(vagrant-libvirt)
|
2006
|
+
exit unless REQUIRED_PLUGINS.all? do |plugin|
|
2007
|
+
Vagrant.has_plugin?(plugin) || (
|
2008
|
+
puts "The #{plugin} plugin is required. Please install it with:"
|
2009
|
+
puts "$ vagrant plugin install #{plugin}"
|
2010
|
+
false
|
2011
|
+
)
|
2012
|
+
end
|
1605
2013
|
```
|
1606
2014
|
|
1607
2015
|
Now you can use bundler to execute Vagrant:
|