depot/cluster/services/consul/agent.nix

28 lines
691 B
Nix
Raw Normal View History

{ config, cluster, lib, tools, ... }:
2023-03-05 21:39:15 +02:00
let
inherit (tools.meta) domain;
2023-03-05 21:39:15 +02:00
inherit (config.networking) hostName;
inherit (cluster.config) hostLinks;
cfg = cluster.config.services.consul;
hl = hostLinks.${hostName}.consul;
in
{
services.consul = {
enable = true;
webUi = true;
extraConfig = {
datacenter = "eu-central";
domain = "sd-magic.${domain}.";
2023-03-06 22:52:29 +02:00
recursors = [ "127.0.0.1" cluster.config.links.dnsResolver.ipv4 ];
2023-03-05 21:39:15 +02:00
server = true;
node_name = config.networking.hostName;
bind_addr = hl.ipv4;
ports.serf_lan = hl.port;
retry_join = map (hostName: hostLinks.${hostName}.consul.tuple) cfg.otherNodes.agent;
};
};
}