From 74e442270bd971d5e6b1e113a23024f1b64cb729 Mon Sep 17 00:00:00 2001 From: Adam Jensen Date: Wed, 15 Nov 2023 07:50:56 -0500 Subject: [PATCH] Migrate to KVM/libvirt provider --- .github/workflows/build.yml | 32 +++++++++++++++------------- Vagrantfile | 42 +++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 967f883..9ac0fa8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,30 +8,34 @@ on: jobs: package-box: name: Package Vagrant Boxes - runs-on: macos-12 + runs-on: ubuntu-22.04 + timeout-minutes: 60 strategy: fail-fast: false matrix: box: - - fbsd_13_2 - - fbsd_12_4 + - fbsd_12 + - fbsd_13 + - fbsd_14 steps: - - name: Install Vagrant - run: brew install vagrant - - name: Cache Vagrant boxes - uses: actions/cache@v3 - with: - path: ~/.vagrant.d - key: ${{ matrix.box }}-vagrant-20231102-${{ hashFiles('Vagrantfile') }} - restore-keys: | - ${{ matrix.box }}-vagrant-20231102- + - name: Display CPU info + run: lscpu + - name: Install Vagrant and QEMU + run: | + sudo apt-get install -qq -o=Dpkg::Use-Pty=0 moreutils + sudo chronic apt-get install -qq -o=Dpkg::Use-Pty=0 vagrant qemu-system virtualbox qemu libvirt-daemon-system libvirt-clients libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev ruby-libvirt ebtables dnsmasq-base - uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: Set up VM + shell: sudo bash {0} run: | - vagrant plugin install vagrant-disksize + vagrant plugin install vagrant-libvirt + vagrant plugin install vagrant-mutate vagrant status - vagrant up ${{ matrix.box }} + vagrant up --provider libvirt ${{ matrix.box }} - name: Package box + shell: sudo bash {0} run: | vagrant package ${{ matrix.box }} --output ${{ matrix.box }}.box ls -ahl *.box diff --git a/Vagrantfile b/Vagrantfile index 085c3c2..f43ecdc 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,15 +1,23 @@ Vagrant.configure("2") do |config| - config.disksize.size = "16GB" + config.vm.define "fbsd_12" do |c| + c.vm.box = "roboxes/freebsd12" + end + + config.vm.define "fbsd_13" do |c| + c.vm.box = "roboxes/freebsd13" + end - config.vm.define "fbsd_13_2" do |c| - c.vm.box = "freebsd/FreeBSD-13.2-STABLE" + config.vm.define "fbsd_14" do |c| + c.vm.box = "roboxes/freebsd14" end - config.vm.define "fbsd_12_4" do |c| - c.vm.box = "freebsd/FreeBSD-12.4-STABLE" + config.vm.provider "libvirt" do |qe| + # https://vagrant-libvirt.github.io/vagrant-libvirt/configuration.html + qe.cpus = 2 + qe.memory = 8192 end - config.vm.synced_folder ".", "/vagrant", disabled: true + config.vm.boot_timeout = 600 config.vm.provision "shell", inline: <<~SHELL set -e @@ -17,10 +25,6 @@ Vagrant.configure("2") do |config| pkg bootstrap pkg update pkg install -y curl bash git gmake sudo llvm libyaml - # Enable Vagrant's Synced Folders feature (sometimes flaky for FreeBSD guests) - #pkg install -y virtualbox-ose-additions-nox11 - #sysrc vboxguest_enable="YES" - #sysrc vboxservice_enable="YES" pkg clean -ay rm -rf /usr/ports /usr/share/doc @@ -49,26 +53,28 @@ Vagrant.configure("2") do |config| curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain 1.72.1 EOF + echo 'Disk usage before cleanup:' + df -h + du -hs /home/vagrant + du -ah / | sort -r -h | head -25 + + echo 'Cleaning up packages' pkg prime-list pkg clean + echo 'Cleaning up unneeded directories' rm -rf /usr/obj /usr/ports /usr/src /usr/tests /usr/lib/debug /var/db # Adapted from bento's minimize.sh. This writes zeroes to the disk so that the empty space is # easily compressed. - dd if=/dev/zero of=/EMPTY bs=1M || true + echo 'Zeroing out empty space' + dd if=/dev/zero of=/EMPTY bs=1G count=4 || true rm -f /EMPTY sync + echo 'Disk usage after cleanup:' df -h du -hs /home/vagrant du -ah / | sort -r -h | head -25 SHELL - - config.vm.provider "virtualbox" do |v| - v.memory = 8192 - v.cpus = 3 - end - - config.vm.boot_timeout = 600 end