feat: prepare for g18-next

This commit is contained in:
2024-06-18 00:08:56 +08:00
parent cb00edf274
commit 21cda95000
5 changed files with 177 additions and 48 deletions

View File

@@ -46,14 +46,17 @@ in
};
eth0Name = lib.mkOption {
type = lib.types.str;
default = "";
description = "Name of eth0 (192.168.16.0/24)";
};
eth1Name = lib.mkOption {
type = lib.types.str;
default = "";
description = "Name of eth1 (thunet)";
};
eth2Name = lib.mkOption {
type = lib.types.str;
default = "";
description = "Name of the RoCE NIC";
};
};
@@ -341,6 +344,14 @@ in
%telegraf ALL = (root) NOPASSWD: /run/current-system/sw/bin/smartctl
'';
})
(lib.mkIf (telegrafCfg.enable && nvidiaCfg.enable) {
services.telegraf.extraConfig = {
inputs.nvidia_smi = {
bin_path = "/run/current-system/sw/bin/nvidia-smi";
tags = { bucket = telegrafCfg.bucket; };
};
};
})
# g series
(lib.mkIf (gCfg.enable) (let
ipSuffix = (builtins.toString (gCfg.serial + 100)); in {
@@ -348,44 +359,6 @@ in
networking.hostName = assert (gCfg.serial > 0); "g" + (builtins.toString gCfg.serial);
networking.search = [ "nasp" ];
networking.nameservers = [ "192.168.16.118" ];
systemd.network.networks."10-eth0" = {
matchConfig.Name = gCfg.eth0Name;
networkConfig = {
DHCP = "no";
IPv6AcceptRA = true;
};
address = [ "192.168.16.${ipSuffix}/24" ];
routes = [
{
routeConfig = {
Gateway = "192.168.16.118";
GatewayOnLink = true;
Metric = 90;
};
}
{
routeConfig = {
Gateway = "fd01:da8:bf:300::1";
GatewayOnLink = true;
Metric = 90;
};
}
];
};
systemd.network.networks."10-eth1" = {
matchConfig.Name = gCfg.eth1Name;
networkConfig = {
DHCP = "yes";
IPv6AcceptRA = true;
};
linkConfig.RequiredForOnline = "no";
};
systemd.network.networks."10-eth2" = {
matchConfig.Name = gCfg.eth2Name;
address = [ "12.12.12.${ipSuffix}/24" ];
linkConfig.RequiredForOnline = "no";
};
networking.interfaces.${gCfg.eth0Name}.wakeOnLan.enable = true;
networking.extraHosts = ''
192.168.16.101 g1-nasp g1
192.168.16.102 g2-nasp g2
@@ -412,10 +385,6 @@ in
iptables -A INPUT -s 192.168.16.0/24 -j ACCEPT
iptables -A INPUT -s 12.12.12.0/24 -j ACCEPT
'';
networking.rxe = {
enable = true;
interfaces = [ "${gCfg.eth2Name}" ];
};
fileSystems."/share" = {
device = "192.168.16.118:/data0/share";
fsType = "nfs";
@@ -431,16 +400,58 @@ in
enable = lib.mkDefault true;
bucket = "g-series";
};
services.telegraf.extraConfig = {
inputs.nvidia_smi = {
bin_path = "/run/current-system/sw/bin/nvidia-smi";
tags = { bucket = "g-series"; };
};
};
services.ntp = {
enable = true;
servers = [ "192.168.16.118" ];
};
}))
(lib.mkIf (gCfg.enable && gCfg.eth0Name != "") {
systemd.network.networks."10-eth0" = {
matchConfig.Name = gCfg.eth0Name;
networkConfig = {
DHCP = "no";
IPv6AcceptRA = true;
};
address = [ "192.168.16.${ipSuffix}/24" ];
routes = [
{
routeConfig = {
Gateway = "192.168.16.118";
GatewayOnLink = true;
Metric = 90;
};
}
{
routeConfig = {
Gateway = "fd01:da8:bf:300::1";
GatewayOnLink = true;
Metric = 90;
};
}
];
};
networking.interfaces.${gCfg.eth0Name}.wakeOnLan.enable = true;
})
(lib.mkIf (gCfg.enable && gCfg.eth1Name != "") {
systemd.network.networks."10-eth1" = {
matchConfig.Name = gCfg.eth1Name;
networkConfig = {
DHCP = "yes";
IPv6AcceptRA = true;
};
linkConfig.RequiredForOnline = "no";
};
})
(lib.mkIf (gCfg.enable && gCfg.eth2Name != "") {
systemd.network.networks."10-eth2" = {
matchConfig.Name = gCfg.eth2Name;
address = [ "12.12.12.${ipSuffix}/24" ];
linkConfig.RequiredForOnline = "no";
};
networking.rxe = {
enable = true;
interfaces = [ "${gCfg.eth2Name}" ];
};
})
]);
}