diff --git a/machines/manager/default.nix b/machines/manager/default.nix index 828c277..fed885b 100644 --- a/machines/manager/default.nix +++ b/machines/manager/default.nix @@ -15,6 +15,7 @@ with lib; ./mail.nix #./beegfs.nix ./ntp.nix + ./dhcp.nix ./netinstall ./cache.nix ./rdma.nix diff --git a/machines/manager/dhcp.nix b/machines/manager/dhcp.nix new file mode 100644 index 0000000..82f0a0d --- /dev/null +++ b/machines/manager/dhcp.nix @@ -0,0 +1,106 @@ +{ pkgs, lib, config, nodes, ... }: + +with lib; + +{ + services.kea = { + dhcp4 = { + enable = true; + settings = { + "valid-lifetime" = 4000; + "renew-timer" = 1000; + "rebind-timer" = 2000; + + "interfaces-config" = { + "interfaces" = [ "mngt" "data" ]; + }; + + "lease-database" = { + "type" = "memfile"; + "persist" = true; + "name" = "/var/lib/kea/dhcp4.leases"; + }; + + "subnet4" = [ + { + "subnet" = "10.32.46.0/24"; + "interface" = "mngt"; + + "option-data" = [ + { + "name" = "routers"; + "data" = "10.32.46.1"; + } + { + "name" = "domain-name-servers"; + "data" = "10.0.0.53,10.1.1.10"; + } + { + "name" = "domain-name"; + "data" = "mngt.${config.networking.domain}"; + } + { + "name" = "domain-search"; + "data" = "mngt.${config.networking.domain}"; + } + ]; + + "pools" = [ + { + "pool" = "10.32.46.100-10.32.46.200"; + } + ]; + + "reservations" = concatLists (mapAttrsToList + (_: node: optional + (node.config.networking.interfaces."mngt".macAddress != null) + { + "hw-address" = node.config.networking.interfaces."mngt".macAddress; + "ip-address" = "10.32.46.${toString (100 + node.options._module.args.value.nodeId)}"; + }) + nodes); + } + + { + "subnet" = "10.32.47.0/24"; + "interface" = "data"; + + "option-data" = [ + { + "name" = "routers"; + "data" = "10.32.47.1"; + } + { + "name" = "domain-name-servers"; + "data" = "10.0.0.53,10.1.1.10"; + } + { + "name" = "domain-name"; + "data" = config.networking.domain; + } + { + "name" = "domain-search"; + "data" = config.networking.domain; + } + ]; + + "pools" = [ + { + "pool" = "10.32.47.100-10.32.47.200"; + } + ]; + + "reservations" = concatLists (mapAttrsToList + (_: node: optional + (node.config.networking.interfaces."data".macAddress != null) + { + "hw-address" = node.config.networking.interfaces."data".macAddress; + "ip-address" = "10.32.47.${toString (100 + node.options._module.args.value.nodeId)}"; + }) + nodes); + } + ]; + }; + }; + }; +} diff --git a/machines/manager/netinstall/default.nix b/machines/manager/netinstall/default.nix index 7887475..f895a02 100644 --- a/machines/manager/netinstall/default.nix +++ b/machines/manager/netinstall/default.nix @@ -7,15 +7,15 @@ with lib; let - targets = { - "50:46:5d:da:0b:d6" = "node-00"; - "50:46:5d:da:0c:56" = "node-01"; - "10:bf:48:1f:a6:8f" = "node-02"; - "10:bf:48:1b:57:47" = "node-03"; - "10:bf:48:19:a2:4d" = "node-04"; - "10:bf:48:1b:56:df" = "node-05"; - "50:46:5d:da:0c:52" = "node-06"; - }; + targets = [ + "node-00" + "node-01" + "node-02" + "node-03" + "node-04" + "node-05" + "node-06" + ]; installer = pkgs.nixos [ ./installer.nix @@ -59,9 +59,9 @@ let message = "NixOS Automatic Installer for ${name}"; }); - api = pkgs.linkFarm "pixiecore-api" (mapAttrs' - (mac: name: nameValuePair "pixiecore/v1/boot/${mac}" (apiEntry name)) - targets); + api = pkgs.linkFarm "pixiecore-api" (listToAttrs (map + (name: nameValuePair "pixiecore/v1/boot/${nodes."${name}".config.networking.interfaces."data".macAddress}" (apiEntry name)) + targets)); in { services.pixiecore = { @@ -85,23 +85,6 @@ in }; }; - services.dhcpd4 = { - enable = true; - interfaces = [ "enp11s0f0" ]; - - extraConfig = '' - option domain-name-servers 10.0.0.53, 10.1.1.10; - option domain-name "${config.networking.domain}"; - - subnet 10.32.47.0 netmask 255.255.255.0 { - interface enp11s0f0; - range 10.32.47.200 10.32.47.230; - - option routers 10.32.47.1; - } - ''; - }; - hpc.hostFile.aliases = [ "boot.${config.networking.domain}" ]; diff --git a/machines/node/default.nix b/machines/node/default.nix index 6402137..ebfb39b 100644 --- a/machines/node/default.nix +++ b/machines/node/default.nix @@ -3,6 +3,10 @@ with lib; +let + nodeName = "node-${fixedWidthNumber 2 id}"; + +in { imports = [ ./hardware.nix @@ -10,6 +14,7 @@ with lib; ./network.nix ./users.nix ./slurm.nix + (import ../nodes.nix).${nodeName} ]; deployment = { @@ -20,10 +25,11 @@ with lib; }; _module.args = { - node-id = id; + nodeId = id; + inherit nodeName; }; - networking.hostName = "node-${fixedWidthNumber 2 id}"; + networking.hostName = nodeName; networking.timeServers = [ "manager.${config.networking.domain}" diff --git a/machines/node/network.nix b/machines/node/network.nix index 5325e5d..93a3d2a 100644 --- a/machines/node/network.nix +++ b/machines/node/network.nix @@ -1,11 +1,11 @@ -{ lib, node-id, ... }: +{ lib, nodeId, ... }: with lib; { networking.interfaces."enp2s0f0" = { ipv4.addresses = [{ - address = "10.32.47.${fixedWidthNumber 3 (100 + node-id)}"; + address = "10.32.47.${fixedWidthNumber 3 (100 + nodeId)}"; prefixLength = 24; }]; }; diff --git a/machines/nodes.nix b/machines/nodes.nix new file mode 100644 index 0000000..f651194 --- /dev/null +++ b/machines/nodes.nix @@ -0,0 +1,30 @@ +{ + "node-00" = { + networking.interfaces."mngt".macAddress = "50:46:5D:DA:0C:C9"; + networking.interfaces."data".macAddress = "50:46:5d:da:0b:d6"; + }; + "node-01" = { + networking.interfaces."mngt".macAddress = "50:46:5D:DA:0C:07"; + networking.interfaces."data".macAddress = "50:46:5d:da:0c:56"; + }; + "node-02" = { + networking.interfaces."mngt".macAddress = "10:BF:48:19:B0:04"; + networking.interfaces."data".macAddress = "10:bf:48:1f:a6:8f"; + }; + "node-03" = { + networking.interfaces."mngt".macAddress = "10:BF:48:19:A4:FE"; + networking.interfaces."data".macAddress = "10:bf:48:1b:57:47"; + }; + "node-04" = { + networking.interfaces."mngt".macAddress = "10:BF:48:19:A2:E2"; + networking.interfaces."data".macAddress = "10:bf:48:19:a2:4d"; + }; + "node-05" = { + networking.interfaces."mngt".macAddress = "10:BF:48:15:00:F5"; + networking.interfaces."data".macAddress = "10:bf:48:1b:56:df"; + }; + "node-06" = { + networking.interfaces."mngt".macAddress = "50:46:5D:DA:0C:09"; + networking.interfaces."data".macAddress = "50:46:5d:da:0c:52"; + }; +}