2024-08-04 16:12:02 +00:00
|
|
|
{ config, lib, pkgs, nodes, modulesPath, ... }:
|
2024-08-01 20:16:48 +00:00
|
|
|
|
|
|
|
# The way the connection is established is specific to the wob01 site and the Intel S2600KPR blades.
|
|
|
|
# Proper netboot is not possible, because while the blades and the APU board (which is the netboot
|
|
|
|
# server here) are in the same L2 network, the uplink connection of each blade is an LACP LAG,
|
|
|
|
# meaning that the switch on the other side will only enable the port if it sees valid LACP packets.
|
|
|
|
# We work around this by presenting a virtual floppy drive using the "IUSB" protocol of the BMC.
|
2024-08-04 16:12:02 +00:00
|
|
|
# This virtual floppy drive contains an per-blade customized initramfs which will initialize the
|
|
|
|
# network connection including IP configuration and load the actual image off hydra.
|
2024-08-01 20:16:48 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
netboot-server-ip = "2a01:584:11::2";
|
2024-08-04 16:12:02 +00:00
|
|
|
netbootNodes = lib.filterAttrs (_: node: node.config.bagel.baremetal.builders.enable && node.config.bagel.baremetal.builders.netboot) nodes;
|
2024-08-01 20:16:48 +00:00
|
|
|
in {
|
2024-08-04 16:12:02 +00:00
|
|
|
|
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion = !(lib.elem 443 config.networking.firewall.allowedTCPPorts);
|
|
|
|
message = ''
|
|
|
|
Port 443 is in networking.firewalls.allowedTCPPorts, but should be only manually
|
|
|
|
allowed for specific IPs and source ports in ${builtins.toJSON __curPos}
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
2024-08-01 20:16:48 +00:00
|
|
|
|
|
|
|
systemd.services = lib.mapAttrs' (nodename: node: let
|
|
|
|
bmcIp = "192.168.1.${toString (node.config.bagel.baremetal.builders.num * 4 + 2)}";
|
2024-08-03 18:28:57 +00:00
|
|
|
notipxe = node.config.system.build.notipxe.config.system.build.usbImage;
|
|
|
|
in lib.nameValuePair "iusb-spoof-${nodename}" {
|
2024-08-03 21:38:21 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2024-08-01 20:16:48 +00:00
|
|
|
serviceConfig = {
|
2024-08-03 18:28:57 +00:00
|
|
|
Restart = "always";
|
2024-08-01 20:16:48 +00:00
|
|
|
};
|
|
|
|
script = ''
|
|
|
|
AUTH_TOKEN=$(${pkgs.iusb-spoof}/bin/make-token ${bmcIp})
|
2024-08-03 18:28:57 +00:00
|
|
|
exec ${pkgs.iusb-spoof}/bin/iusb-spoof -r ${bmcIp} 5123 $AUTH_TOKEN ${notipxe}
|
2024-08-01 20:16:48 +00:00
|
|
|
'';
|
2024-08-04 16:12:02 +00:00
|
|
|
}) netbootNodes;
|
|
|
|
|
|
|
|
# Since the builders are stateless, they can not store their ssh hostkeys
|
|
|
|
networking.firewall.allowedTCPPorts = [ 80 ]; # for ACME
|
|
|
|
networking.firewall.extraInputRules = ''
|
|
|
|
ip6 saddr 2a01:584:11::/64 tcp sport < 1024 tcp dport 443 accept;
|
|
|
|
'';
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts."vpn-gw.wob01.infra.forkos.org" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations = lib.mapAttrs' (nodename: node: let
|
|
|
|
ip = "2a01:584:11::1:${toString node.config.bagel.baremetal.builders.num}";
|
|
|
|
in lib.nameValuePair "/${nodename}/" {
|
|
|
|
root = "/var/www";
|
|
|
|
extraConfig = ''
|
|
|
|
allow ${ip};
|
|
|
|
deny all;
|
|
|
|
'';
|
|
|
|
}) netbootNodes;
|
|
|
|
};
|
|
|
|
};
|
2024-08-01 20:16:48 +00:00
|
|
|
}
|