alpha
Login
or
Join now
lass.pds.lassul.us
/
superconfig
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
1
Pipelines
configs.consul: remove
author
Hermes
committer
lassulus
date
6 days ago
(Oct 14, 2026, 12:28 PM CEST)
commit
d3415c8c
d3415c8c80c01e582136aadf43133872b8a275a9
parent
19f499bc
19f499bc2d55663f63f4067e5cd93bf31050233e
-213
6 changed files
Expand all
Collapse all
Unified
Split
configs
consul.nix
machines
icarus
config.nix
mors
config.nix
neoprism
config.nix
shodan
config.nix
styx
config.nix
-208
configs/consul.nix
Reviewed
···
1
1
-
{
2
2
-
self,
3
3
-
config,
4
4
-
lib,
5
5
-
pkgs,
6
6
-
...
7
7
-
}:
8
8
-
let
9
9
-
inherit (self.inputs.kartei) hosts;
10
10
-
11
11
-
# consul server peers; stockholm policy (krebs/3modules/kartei/overlay.nix),
12
12
-
# not kartei data
13
13
-
consulHosts = [
14
14
-
"aergia"
15
15
-
"blue"
16
16
-
"coaxmetal"
17
17
-
"daedalus"
18
18
-
"green"
19
19
-
"icarus"
20
20
-
"ignavia"
21
21
-
"littleT"
22
22
-
"massulus"
23
23
-
"neoprism"
24
24
-
"orange"
25
25
-
"radio"
26
26
-
"shodan"
27
27
-
"skynet"
28
28
-
"styx"
29
29
-
"ubik"
30
30
-
"yellow"
31
31
-
];
32
32
-
in
33
33
-
{
34
34
-
services.consul = {
35
35
-
enable = true;
36
36
-
# dropPrivileges = false;
37
37
-
webUi = true;
38
38
-
# interface.bind = "retiolum";
39
39
-
extraConfig = {
40
40
-
bind_addr = hosts.${config.networking.hostName}.nets.retiolum.ip4.addr;
41
41
-
bootstrap_expect = 3;
42
42
-
server = true;
43
43
-
# retry_join = config.services.consul.extraConfig.start_join;
44
44
-
retry_join = map (name: lib.head hosts.${name}.nets.retiolum.aliases) consulHosts;
45
45
-
rejoin_after_leave = true;
46
46
-
47
47
-
# try to fix random lock loss on leader reelection
48
48
-
retry_interval = "3s";
49
49
-
50
50
-
# Autopilot configuration for better automatic failure handling
51
51
-
autopilot = {
52
52
-
# Automatically clean up dead servers
53
53
-
cleanup_dead_servers = true;
54
54
-
# How long a server must be stable before promoting
55
55
-
server_stabilization_time = "10s";
56
56
-
# Allow cluster to operate with 2 of 3 nodes (majority quorum)
57
57
-
min_quorum = 2;
58
58
-
};
59
59
-
60
60
-
# Performance tuning - slightly relaxed for network tolerance
61
61
-
performance = {
62
62
-
# 2 = default, gives more time for slow/unstable networks
63
63
-
# 1 was too aggressive and caused leader flapping
64
64
-
raft_multiplier = 2;
65
65
-
};
66
66
-
67
67
-
# Reconnect timeout for failed nodes (default 72h, reduce for faster cleanup)
68
68
-
reconnect_timeout = "24h";
69
69
-
70
70
-
# Leave on terminate for cleaner shutdowns
71
71
-
leave_on_terminate = true;
72
72
-
};
73
73
-
};
74
74
-
75
75
-
# Add systemd override for easier recovery
76
76
-
systemd.services.consul = {
77
77
-
# Add pre-start script to clean up potential issues
78
78
-
preStart = ''
79
79
-
# Ensure proper permissions
80
80
-
chown -R consul:consul /var/lib/consul
81
81
-
'';
82
82
-
83
83
-
# Add recovery commands to service
84
84
-
serviceConfig = {
85
85
-
# Allow consul to restart on failure
86
86
-
Restart = "on-failure";
87
87
-
RestartSec = "5s";
88
88
-
StartLimitBurst = 3;
89
89
-
StartLimitInterval = "60s";
90
90
-
};
91
91
-
};
92
92
-
93
93
-
# Add recovery helper script
94
94
-
environment.systemPackages = [
95
95
-
(pkgs.writeScriptBin "consul-recover" ''
96
96
-
#!${pkgs.stdenv.shell}
97
97
-
set -e
98
98
-
99
99
-
echo "Consul Recovery Tool"
100
100
-
echo "==================="
101
101
-
echo ""
102
102
-
103
103
-
case "''${1:-}" in
104
104
-
force-leave)
105
105
-
if [ -z "''$2" ]; then
106
106
-
echo "Usage: consul-recover force-leave <node-name>"
107
107
-
exit 1
108
108
-
fi
109
109
-
echo "Force removing node ''$2 from cluster..."
110
110
-
consul force-leave "''$2"
111
111
-
;;
112
112
-
113
113
-
reset-cluster)
114
114
-
echo "WARNING: This will completely reset the local consul cluster data!"
115
115
-
echo "Only use this if the cluster is completely broken."
116
116
-
read -p "Are you sure? (yes/no): " confirm
117
117
-
if [ "''$confirm" = "yes" ]; then
118
118
-
echo "Stopping consul..."
119
119
-
systemctl stop consul
120
120
-
echo "Clearing consul data..."
121
121
-
rm -rf /var/lib/consul/*
122
122
-
echo "Starting consul..."
123
123
-
systemctl start consul
124
124
-
echo "Reset complete. This node will rejoin or form a new cluster."
125
125
-
else
126
126
-
echo "Cancelled."
127
127
-
fi
128
128
-
;;
129
129
-
130
130
-
bootstrap-single)
131
131
-
echo "WARNING: This will force this node to bootstrap as a single-node cluster!"
132
132
-
echo "Only use this in emergency recovery scenarios."
133
133
-
read -p "Are you sure? (yes/no): " confirm
134
134
-
if [ "''$confirm" = "yes" ]; then
135
135
-
echo "Stopping consul..."
136
136
-
systemctl stop consul
137
137
-
echo "Clearing consul data..."
138
138
-
rm -rf /var/lib/consul/*
139
139
-
echo "Creating temporary bootstrap configuration..."
140
140
-
cat /etc/consul.json | ${pkgs.jq}/bin/jq '.bootstrap_expect = 1' > /tmp/consul-bootstrap.json
141
141
-
echo "Starting consul in bootstrap mode..."
142
142
-
consul agent -server -data-dir=/var/lib/consul -config-file=/tmp/consul-bootstrap.json -config-file=/etc/consul-addrs.json -config-dir=/etc/consul.d &
143
143
-
CONSUL_PID=$!
144
144
-
sleep 10
145
145
-
echo "Checking cluster status..."
146
146
-
if consul operator raft list-peers; then
147
147
-
echo "Bootstrap successful! Restarting with normal configuration..."
148
148
-
kill $CONSUL_PID
149
149
-
systemctl start consul
150
150
-
else
151
151
-
echo "Bootstrap failed!"
152
152
-
kill $CONSUL_PID 2>/dev/null || true
153
153
-
exit 1
154
154
-
fi
155
155
-
else
156
156
-
echo "Cancelled."
157
157
-
fi
158
158
-
;;
159
159
-
160
160
-
status)
161
161
-
echo "Consul Cluster Status:"
162
162
-
echo "====================="
163
163
-
echo ""
164
164
-
echo "Members:"
165
165
-
consul members || echo "Failed to get members (no leader?)"
166
166
-
echo ""
167
167
-
echo "Raft Peers:"
168
168
-
consul operator raft list-peers || echo "Failed to get raft peers (no leader?)"
169
169
-
echo ""
170
170
-
echo "Service Status:"
171
171
-
systemctl status consul --no-pager | head -20
172
172
-
;;
173
173
-
174
174
-
*)
175
175
-
echo "Usage: consul-recover <command>"
176
176
-
echo ""
177
177
-
echo "Commands:"
178
178
-
echo " status - Show cluster status"
179
179
-
echo " force-leave <node> - Force remove a node from the cluster"
180
180
-
echo " reset-cluster - Completely reset local consul data"
181
181
-
echo " bootstrap-single - Emergency: Bootstrap as single-node cluster"
182
182
-
;;
183
183
-
esac
184
184
-
'')
185
185
-
];
186
186
-
187
187
-
environment.etc."consul.d/testservice.json".text = builtins.toJSON {
188
188
-
service = {
189
189
-
name = "testing";
190
190
-
};
191
191
-
};
192
192
-
193
193
-
networking.firewall.interfaces.retiolum = {
194
194
-
allowedTCPPorts = [
195
195
-
8300
196
196
-
8301
197
197
-
8302
198
198
-
8400
199
199
-
8500
200
200
-
8600
201
201
-
];
202
202
-
allowedUDPPorts = [
203
203
-
8301
204
204
-
8302
205
205
-
8500
206
206
-
];
207
207
-
};
208
208
-
}
-1
machines/icarus/config.nix
View file
Reviewed
···
11
11
../../configs/network-manager.nix
12
12
../../configs/snapclient.nix
13
13
../../configs/gg23/audio/room.nix
14
14
-
../../configs/consul.nix
15
14
../../configs/autoupdate.nix
16
15
../../configs/sigexec/executor.nix
17
16
../../configs/rad.nix
-1
machines/mors/config.nix
View file
Reviewed
···
22
22
../../configs/rtl-sdr.nix
23
23
../../configs/printing
24
24
../../configs/network-manager.nix
25
25
-
../../configs/consul.nix
26
25
../../configs/networkd.nix
27
26
../../configs/autotether.nix
28
27
../../configs/autoupdate.nix
-1
machines/neoprism/config.nix
View file
Reviewed
···
30
30
../../configs/crit-proxy.nix
31
31
32
32
# sync-containers
33
33
-
../../configs/consul.nix
34
33
../../configs/services/flix/container-host.nix
35
34
../../configs/services/radio/container-host.nix
36
35
../../configs/orange-host.nix
-1
machines/shodan/config.nix
View file
Reviewed
···
7
7
../../configs/desktops/qtile/nixos.nix
8
8
../../configs/pipewire.nix
9
9
../../configs/network-manager.nix
10
10
-
../../configs/consul.nix
11
10
../../configs/snapclient.nix
12
11
../../configs/gg23/audio/room.nix
13
12
../../configs/sigexec/executor.nix
-1
machines/styx/config.nix
View file
Reviewed
···
13
13
../../configs/syncthing.nix
14
14
../../configs/ppp/umts-stick.nix
15
15
../../configs/snapclient.nix
16
16
-
../../configs/consul.nix
17
16
../../configs/monitoring/server.nix
18
17
];
19
18