Skip to content

Instantly share code, notes, and snippets.

@panda1100
Created June 9, 2022 06:00
Show Gist options
  • Save panda1100/8f4d7ccc572b93cbf0723d9ce2074c32 to your computer and use it in GitHub Desktop.
Save panda1100/8f4d7ccc572b93cbf0723d9ce2074c32 to your computer and use it in GitHub Desktop.
Vagrantfile for HTTPSBoot Testing Environment
Vagrant.configure("2") do |config|
number_of_node = ENV["NODES"] || 2
config.vm.define :server do |server|
server.vm.box = "rockylinux/8"
server.vm.box_version = "5.0.0"
server.vm.hostname = "httpsboot-srv"
server.vm.network "private_network",
ip: "10.0.0.254",
netmask: "255.255.252.0",
libvirt__network_name: "httpsboot",
libvirt__dhcp_enabled: false
server.vm.provider :libvirt do |libvirt|
libvirt.cpu_mode = "host-passthrough"
libvirt.memory = '4192'
libvirt.cpus = '2'
libvirt.machine_virtual_size = 40
end
server.vm.provision "shell", inline: <<-SHELL
dnf install -y cloud-utils-growpart
growpart /dev/vda 1
xfs_growfs /dev/vda1
SHELL
server.vm.provision "shell", inline: <<-SHELL
dnf install -y vim tree mlocate curl wget git
dnf install -y dhcp-server tftp-server nfs-utils
dnf install -y dnsmasq
dnf install -y https://repo.ctrliq.com/rhel/8/ciq-release.rpm
dnf install -y warewulf
dnf install -y epel-release
dnf install -y make go
dnf groupinstall -y "Development Tools"
dnf install -y libseccomp-devel squashfs-tools cryptsetup
dnf install -y apptainer
SHELL
server.vm.provision "shell", inline: <<-SHELL
cat << 'EOS' > /etc/warewulf/warewulf.conf
ipaddr: 10.0.0.254
netmask: 255.255.252.0
warewulf:
port: 9873
secure: true
autobuild overlays: true
update interval: 60
syslog: false
dhcp:
enabled: true
range start: 10.0.1.1
range end: 10.0.1.255
template: default
systemd name: dhcpd
tftp:
enabled: true
tftproot: /var/lib/tftpboot
systemd name: tftp
nfs:
systemd name: nfs-server
exports:
- /home
- /var/warewulf
EOS
wwctl configure --all
sed -i 's@ExecStart=/usr/bin/wwctl server start@ExecStart=/usr/bin/wwctl server start -d -v@' /usr/lib/systemd/system/warewulfd.service
systemctl enable --now warewulfd
SHELL
server.vm.provision "shell", inline: <<-SHELL
git clone https://github.com/hpcng/warewulf.git
apptainer build --sandbox /tmp/rocky8 warewulf/containers/Apptainer/rocky-8.def
wwctl container import /tmp/rocky8 rocky-8
wwctl container exec rocky-8 /bin/sh <<-CRUB
dnf install -y epel-release
dnf install -y sl
dnf install -y lsof
rm -f /etc/sysconfig/network-scripts/ifcfg-ens3
systemctl enable network
CRUB
wwctl kernel import $(uname -r) --setdefault
wwctl profile set -y default -K $(uname -r) -A "net.ifnames=0 biosdevname=0" -C rocky-8
wwctl profile set -y default --netdev eth1 --netmask 255.255.252.0 --gateway 10.0.0.254
cat << 'EOS' >> /var/warewulf/overlays/system/default/etc/sysconfig/network-scripts/ifcfg-eth1.ww
DEVICE=eth1
NAME=eth1
IPADDR={{$.NetDevs.eth1.Ipaddr}}
NETMASK={{$.NetDevs.eth1.Netmask}}
GATEWAY={{$.NetDevs.eth1.Gateway}}
HWADDR={{$.NetDevs.eth1.Hwaddr}}
DNS1=10.0.0.254
BOOTPROTO=static
ONBOOT=yes
DEVTIMEOUT=10
EOS
cat << 'EOS' > /var/warewulf/overlays/system/default/etc/sysconfig/network-scripts/ifcfg-eth0.ww
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="no"
TYPE="Ethernet"
PERSISTENT_DHCLIENT="yes"
EOS
wwctl overlay build -a
SHELL
(1..number_of_node).each do |i|
server.vm.provision "shell", inline: <<-SHELL
wwctl node add "n000#{i}".cluster --netdev eth1 -I "10.0.1.#{i}" --discoverable
SHELL
end
server.vm.provision "shell", inline: <<-SHELL
wwctl configure hosts
SHELL
end
(1..number_of_node).each do |i|
config.vm.define :"n000#{i}", autostart: false do |node|
node.vm.hostname = "n000#{i}"
node.vm.network "private_network",
libvirt__network_name: "pxe"
node.vm.provider :libvirt do |compute|
compute.cpu_mode = 'host-passthrough'
compute.memory = '4192'
compute.cpus = '1'
boot_network = {'network' => 'httpsboot'}
compute.boot boot_network
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment