Move provisioning to separate file

- Corrected disk size for 18 TB
- Moved provisioning logic to separate script
- Added scratch directory with .gitignore for local overrides
- Fixed VAGRANT_PROV boolean handling to prevent default override
This commit is contained in:
Kris Lamoureux 2025-03-05 22:53:26 -05:00
parent ebf2bfa46a
commit c84c1217ac
Signed by: kris
GPG Key ID: 105B748C1362EB96
4 changed files with 39 additions and 31 deletions

View File

@ -113,8 +113,9 @@ the following available settings:
- Default: `16`
- Number of virtual disks to create (max 676)
- `DISK_SIZE`
- Default: `18T`
- Default: `16763G`
- Size of each virtual disk (sparse allocation)
- Derived from: 18 TB x (1000^4 / 1024^4) = 16.37 TiB or ~16763 GiB
## Copyright and License

37
Vagrantfile vendored
View File

@ -9,14 +9,18 @@ if File.exist?(settings_path)
settings = YAML.load_file(settings_path)
end
# Can't use `||` here because `false || true` evaluates to true
VAGRANT_PROV = settings.key?('VAGRANT_PROV') ? settings['VAGRANT_PROV'] : true
VAGRANT_NAME = settings['VAGRANT_NAME'] || 'zfstest'
VAGRANT_BOX = settings['VAGRANT_BOX'] || 'debian/bookworm64'
VAGRANT_PROV = settings['VAGRANT_PROV'] || true
VAGRANT_CPUS = settings['VAGRANT_CPUS'] || 4
VAGRANT_MEM = settings['VAGRANT_MEM'] || 4096
VAGRANT_SH = settings['VAGRANT_SH'] || ''
NUM_DISKS = settings['NUM_DISKS'] || 16
DISK_SIZE = settings['DISK_SIZE'] || '18T'
# 18 TB decimal/SI to binary/IEC conversion:
# 18 TB x (1000^4 / 1024^4) = 16.37 TiB
# 16.37 TiB x 1024 = ~16763 GiB
DISK_SIZE = settings['DISK_SIZE'] || '16763G'
Vagrant.configure("2") do |config|
config.vm.box = VAGRANT_BOX
@ -49,34 +53,7 @@ Vagrant.configure("2") do |config|
end
if VAGRANT_PROV
config.vm.provision "shell", inline: <<-SHELL
if [ -f /etc/os-release ]; then
. /etc/os-release
OS_ID=$ID
else
echo "Cannot detect OS, exiting"
exit 1
fi
if [ "$OS_ID" = "debian" ]; then
export DEBIAN_FRONTEND=noninteractive
SOURCES_LIST="/etc/apt/sources.list.d/contrib.list"
echo "deb http://deb.debian.org/debian/ ${VERSION_CODENAME} contrib" > "$SOURCES_LIST"
apt-get update
apt-get install -y linux-headers-$(uname -r)
apt-get install -y zfsutils-linux
elif [ "$OS_ID" = "rocky" ]; then
dnf install -y epel-release
dnf config-manager --enable epel
dnf install -y https://zfsonlinux.org/epel/zfs-release-2-3$(rpm --eval "%{dist}").noarch.rpm
dnf config-manager --disable zfs
dnf config-manager --enable zfs-kmod
dnf install -y zfs
else
echo "Unsupported OS: $OS_ID"
exit 1
fi
SHELL
config.vm.provision "shell", path: "provision.sh"
end
if VAGRANT_SH != ''

28
provision.sh Normal file
View File

@ -0,0 +1,28 @@
#!/bin/bash
if [ -f /etc/os-release ]; then
# shellcheck source=/dev/null
. /etc/os-release
OS_ID=$ID
else
echo "Cannot detect OS, exiting"
exit 1
fi
if [ "$OS_ID" = "debian" ]; then
export DEBIAN_FRONTEND=noninteractive
SOURCES_LIST="/etc/apt/sources.list.d/contrib.list"
echo "deb http://deb.debian.org/debian/ ${VERSION_CODENAME} contrib" >"$SOURCES_LIST"
apt-get update
apt-get install -y "linux-headers-$(uname -r)"
apt-get install -y zfsutils-linux
elif [ "$OS_ID" = "rocky" ]; then
dnf install -y epel-release
dnf config-manager --enable epel
dnf install -y "https://zfsonlinux.org/epel/zfs-release-2-3$(rpm --eval "%{dist}").noarch.rpm"
dnf config-manager --disable zfs
dnf config-manager --enable zfs-kmod
dnf install -y zfs
else
echo "Unsupported OS: $OS_ID"
exit 1
fi

2
scratch/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore