cluster/services/consul: init
This commit is contained in:
parent
0129de211e
commit
9a1fa4e418
2 changed files with 41 additions and 0 deletions
24
cluster/services/consul/agent.nix
Normal file
24
cluster/services/consul/agent.nix
Normal 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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
17
cluster/services/consul/default.nix
Normal file
17
cluster/services/consul/default.nix
Normal 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;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue