wip: convert ekman to new cluster sturcture (not complete)
This commit is contained in:
156
ekman/mounts.nix
Normal file
156
ekman/mounts.nix
Normal file
@@ -0,0 +1,156 @@
|
||||
{ lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.cluster.mounts;
|
||||
|
||||
subnet =
|
||||
if cfg.rdma.enable then "243"
|
||||
else if cfg.gbe100.enable then "244"
|
||||
else "241";
|
||||
|
||||
options =
|
||||
[ "soft" "defaults" "vers=4.2" ] ++
|
||||
(if cfg.automount.enable then [ "noauto" "x-systemd.automount" ] else []);
|
||||
|
||||
users =
|
||||
if cfg.users then {
|
||||
"/frontend" = {
|
||||
device = "10.255.241.100:/home";
|
||||
fsType = "nfs4";
|
||||
options = [
|
||||
"soft"
|
||||
"defaults"
|
||||
"noauto"
|
||||
"x-systemd.automount"
|
||||
];
|
||||
};
|
||||
} else {};
|
||||
|
||||
opt =
|
||||
let
|
||||
server = "10.255.241.100";
|
||||
in
|
||||
if cfg.opt then {
|
||||
"/opt/bin" = {
|
||||
device = "${server}:/opt/bin";
|
||||
fsType = "nfs4";
|
||||
inherit options;
|
||||
};
|
||||
"/opt/sif" = {
|
||||
device = "${server}:/opt/sif";
|
||||
fsType = "nfs4";
|
||||
inherit options;
|
||||
};
|
||||
"/opt/singularity" = {
|
||||
device = "${server}:/opt/singularity";
|
||||
fsType = "nfs4";
|
||||
inherit options;
|
||||
};
|
||||
} else {};
|
||||
|
||||
data =
|
||||
if cfg.ceph then {
|
||||
"/data" = {
|
||||
device = "/ceph";
|
||||
options = [ "bind" ];
|
||||
};
|
||||
} else if cfg.backup then {
|
||||
"/data" = {
|
||||
device = "/backup";
|
||||
options = [ "bind" ];
|
||||
};
|
||||
} else {};
|
||||
# device = "10.255.${subnet}.80:/backup";
|
||||
# # device = "10.255.${subnet}.80:/data";
|
||||
# fsType = "nfs4";
|
||||
# inherit options;
|
||||
# };
|
||||
|
||||
work =
|
||||
if cfg.work then {
|
||||
"/work" = {
|
||||
device = "10.255.${subnet}.90:/work";
|
||||
fsType = "nfs4";
|
||||
options = options ++ (if cfg.rdma.enable then [ "rdma" ] else []);
|
||||
};
|
||||
} else {};
|
||||
|
||||
backup =
|
||||
if cfg.backup then {
|
||||
"/backup" = {
|
||||
device = "10.255.${subnet}.80:/backup";
|
||||
fsType = "nfs4";
|
||||
options = options ++ [ "ro" ] ++ (if cfg.rdma.enable then [ "rdma" ] else []);
|
||||
};
|
||||
} else {};
|
||||
|
||||
ceph =
|
||||
if cfg.ceph then {
|
||||
"/ceph" = {
|
||||
device = "oceanbox@.data=/";
|
||||
fsType = "ceph";
|
||||
options = [
|
||||
"mon_addr=10.255.241.30/10.255.241.31/10.255.241.32:6789"
|
||||
"_netdev"
|
||||
];
|
||||
};
|
||||
} else {};
|
||||
|
||||
fileSystems = users // opt // data // work // backup // ceph;
|
||||
|
||||
automount = mountpoint:
|
||||
if cfg.automount.enable && builtins.hasAttr mountpoint fileSystems then
|
||||
[{
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
automountConfig = {
|
||||
TimeoutIdleSec = "600";
|
||||
};
|
||||
where = mountpoint;
|
||||
}]
|
||||
else [];
|
||||
|
||||
automounts =
|
||||
[] ++
|
||||
automount "/work" ++
|
||||
automount "/opt" ++
|
||||
automount "/backup" ++
|
||||
automount "/data";
|
||||
|
||||
cephConf =
|
||||
if cfg.ceph then {
|
||||
"ceph/ceph.conf" = {
|
||||
text = ''
|
||||
[global]
|
||||
mon_host = 10.255.241.30:6789,10.255.241.31:6789,10.244.241.32:6789
|
||||
log file = /tmp/ceph-$pid.log
|
||||
[client.oceanbox]
|
||||
key = AQDQNgRm6IE7JxAA1glJKsWPIBB/H/GxFYM0vQ==
|
||||
[client.rbd]
|
||||
key = AQCjth9mjR41ABAAvSs6hltidQT6Hu5OKwWu+Q==
|
||||
'';
|
||||
mode = "0660";
|
||||
group = "admin";
|
||||
};
|
||||
} else {};
|
||||
|
||||
in
|
||||
{
|
||||
options.cluster.mounts = {
|
||||
rdma.enable = mkEnableOption "Enable NFS over RDMA";
|
||||
gbe100.enable = mkEnableOption "Enable NFS over 100 GbE";
|
||||
automount.enable = mkEnableOption "Enable NFS automounting";
|
||||
users = mkEnableOption "Enable /users";
|
||||
opt = mkEnableOption "Enable /opt";
|
||||
data = mkEnableOption "Enable /data";
|
||||
work = mkEnableOption "Enable /work";
|
||||
backup = mkEnableOption "Enable /backup";
|
||||
ceph = mkEnableOption "Enable /ceph";
|
||||
};
|
||||
|
||||
config = {
|
||||
fileSystems = fileSystems;
|
||||
environment.etc = cephConf;
|
||||
systemd.automounts = automounts;
|
||||
boot.kernelModules = [ "rbd" ];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user