Archived
49 lines
2.0 KiB
Nix
49 lines
2.0 KiB
Nix
# HA file server build type: DRBD + XFS + LIO iSCSI + NFS, managed by
|
|
# Corosync + Pacemaker. Both ha-server-1 and ha-server-2 use this type.
|
|
#
|
|
# NFS start/stop:
|
|
# services.nfs.server.enable = true configures /etc/exports, wires up
|
|
# rpcbind, and loads kernel modules — but nfs-server.service.wantedBy is
|
|
# force-cleared so systemd does NOT auto-start it at boot. Pacemaker's
|
|
# ha-group resource group (configured by scripts/ha/cluster-init.sh)
|
|
# starts and stops nfs-server as part of the failover sequence after the
|
|
# XFS mount and iSCSI target are brought up on the new Active node.
|
|
#
|
|
# Beszel agent:
|
|
# Enabled here via enable-agent.nix. The agent KEY (used to pair with
|
|
# the Beszel hub) is not set yet — add it to hosts/ha-server-{1,2}/host.nix
|
|
# under services.beszel.agent.environment.KEY once the hub accepts the
|
|
# new agents, following the pattern in hosts/server/host.nix.
|
|
{ lib, pkgs, vars, ... }:
|
|
|
|
let
|
|
# Generates /etc/exports lines for all nfsShares data entries. Shared
|
|
# pattern with modules/build-types/server.nix — both export the same
|
|
# set of shares, differing only in the storage root they serve from.
|
|
mkNfsExports = storageRoot:
|
|
lib.concatMapStrings
|
|
(share: " ${storageRoot}/${share.subpath} ${vars.lanCidr}${vars.nfsShares.options}\n")
|
|
(lib.filter builtins.isAttrs (lib.attrValues vars.nfsShares));
|
|
in
|
|
{
|
|
imports = [
|
|
../ha/pacemaker-stack.nix
|
|
../ha/iscsi-target.nix
|
|
../ha/cluster-config.nix
|
|
../beszel/enable-agent.nix
|
|
];
|
|
|
|
# xfsprogs: mkfs.xfs/xfs_info needed by cluster-init.sh.
|
|
# openiscsi: iscsiadm needed by acceptance-tests.sh T4 (iSCSI discovery check).
|
|
environment.systemPackages = [ pkgs.xfsprogs pkgs.openiscsi ];
|
|
|
|
services.nfs.server = {
|
|
enable = true;
|
|
exports = mkNfsExports vars.haStorageRoot;
|
|
};
|
|
|
|
# Pacemaker controls nfs-server — prevent systemd from starting it at boot
|
|
# on both nodes (only the Active node should be serving NFS).
|
|
systemd.services.nfs-server.wantedBy = lib.mkForce [ ];
|
|
}
|