summaryrefslogtreecommitdiffstats
path: root/nixos/tests/consul.nix
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2020-06-18 01:48:19 +0200
committerNiklas Hambüchen <mail@nh2.me>2020-06-18 02:22:26 +0200
commit777d1c0944e931bf5bb3538982c144b8916d1b97 (patch)
tree1f556f5f9898c860be1a38c6a20594678dea504a /nixos/tests/consul.nix
parentf795df26cfd0cb746be89f9e004a25d85e0d8465 (diff)
consul.passthru.tests: Refactor let bindings
Diffstat (limited to 'nixos/tests/consul.nix')
-rw-r--r--nixos/tests/consul.nix13
1 files changed, 5 insertions, 8 deletions
diff --git a/nixos/tests/consul.nix b/nixos/tests/consul.nix
index 785963d1a7cc..a5188d128304 100644
--- a/nixos/tests/consul.nix
+++ b/nixos/tests/consul.nix
@@ -55,31 +55,28 @@ let
server = index: { pkgs, ... }:
let
- ip = builtins.elemAt allConsensusServerHosts index;
+ thisConsensusServerHost = builtins.elemAt allConsensusServerHosts index;
+ ip = thisConsensusServerHost; # since we already use IPs to identify servers
in
{
networking.interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
- { address = builtins.elemAt allConsensusServerHosts index; prefixLength = 16; }
+ { address = ip; prefixLength = 16; }
];
networking.firewall = firewallSettings;
services.consul =
- let
- thisConsensusServerHost = builtins.elemAt allConsensusServerHosts index;
- numConsensusServers = builtins.length allConsensusServerHosts;
- in
assert builtins.elem thisConsensusServerHost allConsensusServerHosts;
{
enable = true;
inherit webUi;
extraConfig = defaultExtraConfig // {
server = true;
- bootstrap_expect = numConsensusServers;
+ bootstrap_expect = builtins.length allConsensusServerHosts;
retry_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.
# See https://github.com/hashicorp/consul/issues/2868
- if numConsensusServers == 1
+ if builtins.length allConsensusServerHosts == 1
then allConsensusServerHosts
else builtins.filter (h: h != thisConsensusServerHost) allConsensusServerHosts;
bind_addr = ip;