aboutsummaryrefslogtreecommitdiff
path: root/configuration.nix
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-11-02 11:49:28 +0100
committerAlex Auvolat <alex@adnab.me>2021-11-02 11:49:28 +0100
commit4d16e394560c64f2aa9a26f2b18d4b31009f86fc (patch)
tree87ebb85d0266669b278d9c9a84438c4ddcad1efe /configuration.nix
parent596a1e2e5d6820462b7e4f16abcd47ee6290606f (diff)
downloadnixcfg-4d16e394560c64f2aa9a26f2b18d4b31009f86fc.tar.gz
nixcfg-4d16e394560c64f2aa9a26f2b18d4b31009f86fc.zip
Make a Consul+Nomad cluster
Diffstat (limited to 'configuration.nix')
-rw-r--r--configuration.nix48
1 files changed, 44 insertions, 4 deletions
diff --git a/configuration.nix b/configuration.nix
index f25efc7..6dcf30e 100644
--- a/configuration.nix
+++ b/configuration.nix
@@ -2,8 +2,11 @@
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
-{ config, pkgs, ... }:
+{ config, pkgs, ... } @ args:
+# Configuration local for this cluster node (hostname, IP, etc)
+let node_config = import ./node.nix args;
+in
{
imports =
[ # Include the results of the hardware scan.
@@ -115,16 +118,53 @@
# };
# List services that you want to enable:
-
+
# Enable network time
services.ntp.enable = true;
# Enable the OpenSSH daemon.
services.openssh.enable = true;
+ # Enable Hashicorp Consul & Nomad
+ services.consul.enable = true;
+ services.consul.extraConfig =
+ let public_ip = (builtins.head node_config.networking.interfaces.eno1.ipv4.addresses).address;
+ in
+ {
+ datacenter = "neptune";
+ bootstrap_expect = 3;
+ server = true;
+ ui = true;
+ bind_addr = public_ip;
+ addresses.http = "0.0.0.0";
+ retry_join = [ "192.168.1.21" "192.168.1.22" "192.168.1.23" ];
+ };
+
+ services.nomad.enable = true;
+ services.nomad.settings =
+ let public_ip = (builtins.head node_config.networking.interfaces.eno1.ipv4.addresses).address;
+ in
+ {
+ datacenter = "neptune";
+ server = {
+ enabled = true;
+ bootstrap_expect = 3;
+ };
+ advertise = {
+ rpc = public_ip;
+ http = public_ip;
+ serf = public_ip;
+ };
+ consul.address = "127.0.0.1:8500";
+ client = {
+ enabled = true;
+ network_interface = "eno1";
+ };
+ };
+
# Open ports in the firewall.
- networking.firewall.allowedTCPPorts = [ 22 ];
- # networking.firewall.allowedUDPPorts = [ ... ];
+ networking.firewall.allowedTCPPorts = [ 22 4646 4647 4648 8500 8300 8301 8302 ];
+ networking.firewall.allowedUDPPorts = [ 4648 8301 8302 ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;