consul.passthru.tests: Refactor let bindings
This commit is contained in:
parent
f795df26cf
commit
777d1c0944
@ -55,31 +55,28 @@ let
|
|||||||
|
|
||||||
server = index: { pkgs, ... }:
|
server = index: { pkgs, ... }:
|
||||||
let
|
let
|
||||||
ip = builtins.elemAt allConsensusServerHosts index;
|
thisConsensusServerHost = builtins.elemAt allConsensusServerHosts index;
|
||||||
|
ip = thisConsensusServerHost; # since we already use IPs to identify servers
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
|
networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
|
||||||
{ address = builtins.elemAt allConsensusServerHosts index; prefixLength = 16; }
|
{ address = ip; prefixLength = 16; }
|
||||||
];
|
];
|
||||||
networking.firewall = firewallSettings;
|
networking.firewall = firewallSettings;
|
||||||
|
|
||||||
services.consul =
|
services.consul =
|
||||||
let
|
|
||||||
thisConsensusServerHost = builtins.elemAt allConsensusServerHosts index;
|
|
||||||
numConsensusServers = builtins.length allConsensusServerHosts;
|
|
||||||
in
|
|
||||||
assert builtins.elem thisConsensusServerHost allConsensusServerHosts;
|
assert builtins.elem thisConsensusServerHost allConsensusServerHosts;
|
||||||
{
|
{
|
||||||
enable = true;
|
enable = true;
|
||||||
inherit webUi;
|
inherit webUi;
|
||||||
extraConfig = defaultExtraConfig // {
|
extraConfig = defaultExtraConfig // {
|
||||||
server = true;
|
server = true;
|
||||||
bootstrap_expect = numConsensusServers;
|
bootstrap_expect = builtins.length allConsensusServerHosts;
|
||||||
retry_join =
|
retry_join =
|
||||||
# If there's only 1 node in the network, we allow self-join;
|
# If there's only 1 node in the network, we allow self-join;
|
||||||
# otherwise, the node must not try to join itself, and join only the other servers.
|
# otherwise, the node must not try to join itself, and join only the other servers.
|
||||||
# See https://github.com/hashicorp/consul/issues/2868
|
# See https://github.com/hashicorp/consul/issues/2868
|
||||||
if numConsensusServers == 1
|
if builtins.length allConsensusServerHosts == 1
|
||||||
then allConsensusServerHosts
|
then allConsensusServerHosts
|
||||||
else builtins.filter (h: h != thisConsensusServerHost) allConsensusServerHosts;
|
else builtins.filter (h: h != thisConsensusServerHost) allConsensusServerHosts;
|
||||||
bind_addr = ip;
|
bind_addr = ip;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user