Last active
March 25, 2022 08:56
-
-
Save panda1100/41ecafa7ad77bf3a79d1d8263539a03d to your computer and use it in GitHub Desktop.
Vagrantfile - Warewulf v4 Sandbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant.configure("2") do |config| | |
number_of_node = 2 | |
config.vm.define :server do |server| | |
server.vm.box = "rockylinux/8" | |
server.vm.box_version = "4.0.0" | |
server.vm.hostname = "warewulf-server" | |
server.vm.network "private_network", | |
ip: "10.0.0.254", | |
netmask: "255.255.252.0", | |
libvirt__network_name: "pxe", | |
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 https://repo.ctrliq.com/rhel/8/ciq-release.rpm | |
dnf install -y warewulf | |
dnf install -y epel-release | |
dnf install -y bind-utils | |
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 | |
wwctl container import docker://warewulf/rocky rocky-8 | |
wwctl container exec rocky-8 /bin/sh <<-CRUB | |
dnf install -y epel-release | |
dnf install -y sl | |
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 --netdefault | |
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}} | |
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="yes" | |
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' => 'pxe'} | |
compute.boot boot_network | |
end | |
end | |
end | |
end |
Author
panda1100
commented
Mar 24, 2022
How to use this Vagrantfile
https://medium.com/@panda1100/warewulf-v4-sandboxing-environment-on-kvm-using-vagrant-f0e23fc1ce52
todo:
vagrant plugin install vagrant-secret
gh pr checkout PR_ID
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment