Move common nix code one level up.

This commit is contained in:
2023-11-26 09:36:17 +00:00
parent dfd472ebe8
commit 361dd002d5
26 changed files with 8 additions and 8 deletions

32
common/consul.nix Normal file
View File

@@ -0,0 +1,32 @@
{ pkgs, config, ... }:
let
servers = [ "c1" "c2" "c3" ];
server_enabled = builtins.elem config.networking.hostName servers;
in
{
services.consul = {
enable = true;
webUi = true;
interface.advertise = "eno1";
extraConfig = {
client_addr = "0.0.0.0";
datacenter = "alo";
server = server_enabled;
bootstrap_expect = (builtins.length servers + 2) / 2;
retry_join = builtins.filter (elem: elem != config.networking.hostName) servers;
telemetry = {
prometheus_retention_time = "24h";
disable_hostname = true;
};
};
};
environment.persistence."/persist".directories = [
"/var/lib/consul"
];
networking.firewall = {
allowedTCPPorts = [ 8600 8500 8301 8302 8300 ];
allowedUDPPorts = [ 8600 8301 8302 ];
};
}