# -*- mode: ruby -*- # vi: set ft=ruby : require 'yaml' # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" # configs, custom updates defaults defaults_cfg = YAML.load_file('vagrant-settings.yaml_defaults') if File.exist?('vagrant-settings.yaml') custom_cfg = YAML.load_file('vagrant-settings.yaml') cfg = defaults_cfg.merge(custom_cfg) else cfg = defaults_cfg end Vagrant.configure("2") do |config| config.vm.box = "generic/rhel9" config.vm.hostname = "rhel9u2.example.org" config.vm.synced_folder "../vagrantdata", "/home/vagrant/data" config.vm.provider "virtualbox" do |vb| # vb.gui = true is needed so we can modify the initial boot command line in # VirtualBox 7.0.8 on macOS Ventura as there appears to be a regression in # VboxSVGA driver. Possible that a test build of 7.0.9 (or newer) may # resolve but I've not tested that. # For whatever reason in VB7 on macOS removing the vga=792 (1024x768x24) # kernel boot option will temporarily resolve the issue. # Access to the boot menu in VB7 on macOS by pressing fn-F12 early in # the boot sequence and modify kernel boot params to remove vga=792. vb.gui = true vb.memory = "2048" vb.cpus = "2" end # Unregister from rhsm if registered config.trigger.before :destroy do |trigger| trigger.warn = "Unregistering from rhsm" trigger.run_remote = {inline: "subscription-manager status || exit 0;subscription-manager remove --all; subscription-manager unregister"} end # Must be registered to update and/or install packages config.vm.provision "shell", inline: <<-SHELL subscription-manager register --force \ --auto-attach \ --username=#{cfg["rhsm_username"]} \ --password=#{cfg["rhsm_password"]} SHELL config.vm.provision "shell", inline: <<-SHELL dnf -y update SHELL config.vm.provision "shell", inline: <<-SHELL dnf -y --enablerepo=epel install diffstat jq python3-jsonpatch rpminspect rpminspect-data-generic vim-enhanced SHELL # NOTE: Current generic/rocky9 box is RHEL 9.1 and the above `dnf -y update` will upgrade # it to RHEL 9.2. This will include a new kernel and will break support for VirtualBox # Shared Folders. You will need to build a new kmod for the updated kernel. # In the centos/rocky Vagrant machines this is straight-forward as the boxomatic # boxes leave the build requirements installed. The generic/rhel9 box has these # removed so more work is required to get working vboxsf kmod. config.vm.provision "shell", inline: <<-SHELL dnf install -y gcc make perl kernel-devel kernel-headers bzip2 dkms cd /dev/shm # NOTE: If you are running an older version of VirtualBox probably better to download # matching VBoxGuestAdditions_.iso and install from that. curl -LOR https://download.virtualbox.org/virtualbox/7.0.8/VBoxGuestAdditions_7.0.8.iso mkdir -p /mnt/virtualbox mount -o loop /dev/shm/VBoxGuestAdditions_7.0.8.iso /mnt/virtualbox /mnt/virtualbox VBoxLinuxAdditions.run --nox11 # This will either rebuild the kernel modules for the running kernel or build # the kernel modules for an updated kernel if a newer one exists kver=$(rpm -q --queryformat="%{VERSION}-%{RELEASE}.%{ARCH}\n" kernel | sort -V | tail -n 1) test -x /sbin/rcvboxadd && /sbin/rcvboxadd quicksetup "${kver}" SHELL config.vm.provision :reload # NOTE: If, after reload, the box doesn't mount the VirtualBox shared folders # try installing the Guest Additions again following the sequence above # and then halt and up the box. end