cluster/services/consul: init

This commit is contained in:
Max Headroom 2023-03-05 20:39:15 +01:00
parent 0129de211e
commit 9a1fa4e418
2 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,24 @@
{ config, cluster, lib, ... }:
let
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 = "pve1";
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;
};
};
}

View file

@ -0,0 +1,17 @@
{ config, lib, ... }:
let
cfg = config.services.consul;
in
{
hostLinks = lib.genAttrs cfg.nodes.agent (hostName: {
consul = {
ipv4 = config.vars.mesh.${hostName}.meshIp;
};
});
services.consul = {
nodes.agent = [ "checkmate" "VEGAS" ];
nixos.agent = ./agent.nix;
};
}