第12章 Creating Vagrant boxes with RHEL image builder
With RHEL image builder, you can choose between the vagrant-libvirt or vagrant-virtualbox image types to create Vagrant boxes.
RHEL image builder generates pre-configured images optimized for different hypervisors:
-
vagrant-libvirtcreates a QCOW2-based image forlibvirt -
vagrant-virtualboxcreates a VMDK-based image forVirtualBox
The pre-configured images include the vagrant user with sudo privileges. This configuration simplifies administrative tasks within the Vagrant box.
The images are supported in the following architectures: aarch64 and x86_64.
12.1. Building Vagrant images for the libvirt and VirtualBox backends リンクのコピーリンクがクリップボードにコピーされました!
You can use RHEL image builder to create custom Vagrant boxes for different providers by using the vagrant-libvirt and vagrant-virtualbox image types.
-
The
vagrant-libvirtimage type creates aQCOW2-based box for use with thelibvirtprovider. -
The
vagrant-virtualboximage type creates a box compatible with theVirtualBoxprovider.
You can customize the image type by using blueprint customizations.
Prerequisites
- RHEL image builder is installed and running.
- You have a blueprint file ready to build.
-
For the
libvirt box: A host system with thelibvirthypervisor is installed and running. -
For the
VirtualBoxbox: A host system withVirtualBoxis installed.
Procedure
Build the Vagrant box image:
For
libvirt:$ sudo image-builder build --distro rhel-10.0 vagrant-libvirtFor
VirtualBox:$ sudo image-builder build - -distro <distro-name> vagrant-virtualboxThis creates a
.boxfile.
Import the new
.boxfile to your local Vagrant environment. You must explicitly set theprovidertovirtualboxbecause it is not the standard provider.$ vagrant box add --provider=virtualbox <path/to/box> --name=<box-name>Replace
path/to/image-name.boxwith the actual path to your file and<box_name>with a name such asrhel10-vagrant.Create a new directory for your project, and initialize Vagrant:
$ mkdir <my_vagrant_project> $ cd <my_vagrant_project> $ vagrant init <box-name>This creates the
Vagrantfileconfiguration file and sets its default box to <box-name>.Launch the virtual machine by using Vagrant:
$ vagrant up