{ config, lib, pkgs, ... }: { environment.systemPackages = with pkgs; let containers = builtins.attrNames ( lib.filterAttrs (_: { role, ... }: role == "container" ) config.site.hosts ); resources = builtins.toFile "cib-resources.xml" '' ${lib.concatMapStrings (container: '' '') containers} ''; cib-set-resources = writeScriptBin "cib-set-resources" '' #! ${runtimeShell} -e crm_attribute -t crm_config -n stonith-enabled -v false cibadmin --replace --scope resources --xml-file ${resources} ''; in [ cib-set-resources ]; services.corosync = { enable = true; clusterName = "zentralwerk-network"; nodelist = lib.imap (n: hostName: { nodeid = n; name = hostName; ring_addrs = map (net: config.site.net.${net}.hosts4.${hostName} ) [ "cluster" "mgmt" ]; }) ( builtins.filter (hostName: config.site.hosts.${hostName}.role == "server" ) (builtins.attrNames config.site.hosts) ); }; environment.etc."corosync/authkey" = { source = builtins.toFile "authkey" config.site.cluster.corosyncAuthKey; mode = "0400"; }; services.pacemaker = { enable = true; }; }