Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 4cbfe16

Browse files
committed
Migrate to KVM/libvirt provider
1 parent 95df78c commit 4cbfe16

File tree

2 files changed

+43
-32
lines changed

2 files changed

+43
-32
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,34 @@ on:
88
jobs:
99
package-box:
1010
name: Package Vagrant Boxes
11-
runs-on: macos-12
11+
runs-on: ubuntu-22.04
12+
timeout-minutes: 60
1213
strategy:
1314
fail-fast: false
1415
matrix:
1516
box:
16-
- fbsd_13_2
17-
- fbsd_12_4
17+
- fbsd_12
18+
- fbsd_13
19+
- fbsd_14
1820
steps:
19-
- name: Install Vagrant
20-
run: brew install vagrant
21-
- name: Cache Vagrant boxes
22-
uses: actions/cache@v3
23-
with:
24-
path: ~/.vagrant.d
25-
key: ${{ matrix.box }}-vagrant-20231102-${{ hashFiles('Vagrantfile') }}
26-
restore-keys: |
27-
${{ matrix.box }}-vagrant-20231102-
21+
- name: Display CPU info
22+
run: lscpu
23+
- name: Install Vagrant and QEMU
24+
run: |
25+
sudo apt-get install -qq -o=Dpkg::Use-Pty=0 moreutils
26+
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
2827
- uses: actions/checkout@v3
28+
- name: Set up QEMU
29+
uses: docker/setup-qemu-action@v3
2930
- name: Set up VM
31+
shell: sudo bash {0}
3032
run: |
31-
vagrant plugin install vagrant-disksize
33+
vagrant plugin install vagrant-libvirt
34+
vagrant plugin install vagrant-mutate
3235
vagrant status
33-
vagrant up ${{ matrix.box }}
36+
vagrant up --provider libvirt ${{ matrix.box }}
3437
- name: Package box
38+
shell: sudo bash {0}
3539
run: |
3640
vagrant package ${{ matrix.box }} --output ${{ matrix.box }}.box
3741
ls -ahl *.box

Vagrantfile

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
Vagrant.configure("2") do |config|
2-
config.disksize.size = "16GB"
2+
config.vm.define "fbsd_12" do |c|
3+
c.vm.box = "roboxes/freebsd12"
4+
end
5+
6+
config.vm.define "fbsd_13" do |c|
7+
c.vm.box = "roboxes/freebsd13"
8+
end
39

4-
config.vm.define "fbsd_13_2" do |c|
5-
c.vm.box = "freebsd/FreeBSD-13.2-STABLE"
10+
config.vm.define "fbsd_14" do |c|
11+
c.vm.box = "roboxes/freebsd14"
612
end
713

8-
config.vm.define "fbsd_12_4" do |c|
9-
c.vm.box = "freebsd/FreeBSD-12.4-STABLE"
14+
config.vm.provider "libvirt" do |qe|
15+
# https://vagrant-libvirt.github.io/vagrant-libvirt/configuration.html
16+
qe.driver = "kvm"
17+
qe.cpus = 1
18+
qe.memory = 8192
1019
end
1120

12-
config.vm.synced_folder ".", "/vagrant", disabled: true
21+
config.vm.boot_timeout = 600
1322

1423
config.vm.provision "shell", inline: <<~SHELL
1524
set -e
1625
1726
pkg bootstrap
1827
pkg update
1928
pkg install -y curl bash git gmake sudo llvm libyaml
20-
# Enable Vagrant's Synced Folders feature (sometimes flaky for FreeBSD guests)
21-
#pkg install -y virtualbox-ose-additions-nox11
22-
#sysrc vboxguest_enable="YES"
23-
#sysrc vboxservice_enable="YES"
2429
pkg clean -ay
2530
rm -rf /usr/ports /usr/share/doc
2631
@@ -49,26 +54,28 @@ Vagrant.configure("2") do |config|
4954
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain 1.72.1
5055
EOF
5156
57+
echo 'Disk usage before cleanup:'
58+
df -h
59+
du -hs /home/vagrant
60+
du -ah / | sort -r -h | head -25
61+
62+
echo 'Cleaning up packages'
5263
pkg prime-list
5364
pkg clean
5465
66+
echo 'Cleaning up unneeded directories'
5567
rm -rf /usr/obj /usr/ports /usr/src /usr/tests /usr/lib/debug /var/db
5668
5769
# Adapted from bento's minimize.sh. This writes zeroes to the disk so that the empty space is
5870
# easily compressed.
59-
dd if=/dev/zero of=/EMPTY bs=1M || true
71+
echo 'Zeroing out empty space'
72+
dd if=/dev/zero of=/EMPTY bs=1G count=4 || true
6073
rm -f /EMPTY
6174
sync
6275
76+
echo 'Disk usage after cleanup:'
6377
df -h
6478
du -hs /home/vagrant
6579
du -ah / | sort -r -h | head -25
6680
SHELL
67-
68-
config.vm.provider "virtualbox" do |v|
69-
v.memory = 8192
70-
v.cpus = 3
71-
end
72-
73-
config.vm.boot_timeout = 600
7481
end

0 commit comments

Comments
 (0)