From 1938dc9b54963ecc79c5f74ae502e09235873300 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Mon, 11 May 2015 16:27:53 -0700 Subject: nixos/consul: Remove the joinNodes and joinRetries options as they are now built in consul options --- nixos/modules/services/networking/consul.nix | 37 +++------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) (limited to 'nixos/modules/services/networking/consul.nix') diff --git a/nixos/modules/services/networking/consul.nix b/nixos/modules/services/networking/consul.nix index 5308fd995085..23e5b2f5e7ea 100644 --- a/nixos/modules/services/networking/consul.nix +++ b/nixos/modules/services/networking/consul.nix @@ -6,11 +6,9 @@ let dataDir = "/var/lib/consul"; cfg = config.services.consul; - configOptions = { - data_dir = dataDir; - } - // (if cfg.webUi then { ui_dir = "${pkgs.consul.ui}"; } else { }) - // cfg.extraConfig; + configOptions = { data_dir = dataDir; } // + (if cfg.webUi then { ui_dir = "${pkgs.consul.ui}"; } else { }) // + cfg.extraConfig; configFiles = [ "/etc/consul.json" "/etc/consul-addrs.json" ] ++ cfg.extraConfigFiles; @@ -52,23 +50,6 @@ in ''; }; - joinNodes = mkOption { - type = types.listOf types.str; - default = [ ]; - description = '' - A list of addresses of nodes which should be joined at startup if the - current node is in a left state. - ''; - }; - - joinRetries = mkOption { - type = types.int; - default = 10; - description = '' - The number of times to retry connecting to the join nodes. - ''; - }; - interface = { advertise = mkOption { @@ -219,18 +200,6 @@ in + '' echo "}" >> /etc/consul-addrs.json ''; - postStart = '' - # Issues joins to nodes which we statically connect to - ${flip concatMapStrings cfg.joinNodes (addr: '' - for i in {0..${toString cfg.joinRetries}}; do - # Try to join the other nodes ${toString cfg.joinRetries} times before failing - consul join "${addr}" && break - sleep 1 - done & - '')} - wait - exit 0 - ''; }; systemd.services.consul-alerts = mkIf (cfg.alerts.enable) { -- cgit 1.4.1 From b6e26aa8df5fc37c0d7f9e89f3c2716871697d2d Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Mon, 11 May 2015 16:45:04 -0700 Subject: nixos/consul: Support a config directory for health checks --- nixos/modules/services/networking/consul.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'nixos/modules/services/networking/consul.nix') diff --git a/nixos/modules/services/networking/consul.nix b/nixos/modules/services/networking/consul.nix index 23e5b2f5e7ea..75e2a6921410 100644 --- a/nixos/modules/services/networking/consul.nix +++ b/nixos/modules/services/networking/consul.nix @@ -144,6 +144,8 @@ in environment = { etc."consul.json".text = builtins.toJSON configOptions; + # We need consul.d to exist for consul to start + etc."consul.d/dummy.json".text = "{ }"; systemPackages = with pkgs; [ consul ]; }; @@ -151,10 +153,12 @@ in wantedBy = [ "multi-user.target" ]; after = [ "network.target" ] ++ systemdDevices; bindsTo = systemdDevices; - restartTriggers = [ config.environment.etc."consul.json".source ]; + restartTriggers = [ config.environment.etc."consul.json".source ] + ++ mapAttrsToList (_: d: d.source) + (filterAttrs (n: _: hasPrefix "consul.d/" n) config.environment.etc); serviceConfig = { - ExecStart = "@${pkgs.consul}/bin/consul consul agent" + ExecStart = "@${pkgs.consul}/bin/consul consul agent -config-dir /etc/consul.d" + concatMapStrings (n: " -config-file ${n}") configFiles; ExecReload = "${pkgs.consul}/bin/consul reload"; PermissionsStartOnly = true; -- cgit 1.4.1 From 2806491cc410527aace39395fa521d6df1326967 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Mon, 11 May 2015 17:44:07 -0700 Subject: nixos/consul: Add shell for health checks --- nixos/modules/services/networking/consul.nix | 2 ++ 1 file changed, 2 insertions(+) (limited to 'nixos/modules/services/networking/consul.nix') diff --git a/nixos/modules/services/networking/consul.nix b/nixos/modules/services/networking/consul.nix index 75e2a6921410..53a9f4626254 100644 --- a/nixos/modules/services/networking/consul.nix +++ b/nixos/modules/services/networking/consul.nix @@ -140,6 +140,8 @@ in users.extraUsers."consul" = { description = "Consul agent daemon user"; uid = config.ids.uids.consul; + # The shell is needed for health checks + shell = "/run/current-system/sw/bin/bash"; }; environment = { -- cgit 1.4.1