nixos/nomad: add extraSettingsFiles option to nomad service (#109761)
This commit is contained in:
parent
1af6e3aeed
commit
f1778cd90e
|
@ -49,6 +49,17 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extraSettingsPaths = mkOption {
|
||||||
|
type = types.listOf types.path;
|
||||||
|
default = [];
|
||||||
|
description = ''
|
||||||
|
Additional settings paths used to configure nomad. These can be files or directories.
|
||||||
|
'';
|
||||||
|
example = literalExample ''
|
||||||
|
[ "/etc/nomad-mutable.json" "/run/keys/nomad-with-secrets.json" "/etc/nomad/config.d" ]
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = format.type;
|
type = format.type;
|
||||||
default = {};
|
default = {};
|
||||||
|
@ -101,7 +112,8 @@ in
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = cfg.dropPrivileges;
|
DynamicUser = cfg.dropPrivileges;
|
||||||
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
||||||
ExecStart = "${cfg.package}/bin/nomad agent -config=/etc/nomad.json";
|
ExecStart = "${cfg.package}/bin/nomad agent -config=/etc/nomad.json" +
|
||||||
|
concatMapStrings (path: " -config=${path}") cfg.extraSettingsPaths;
|
||||||
KillMode = "process";
|
KillMode = "process";
|
||||||
KillSignal = "SIGINT";
|
KillSignal = "SIGINT";
|
||||||
LimitNOFILE = 65536;
|
LimitNOFILE = 65536;
|
||||||
|
|
|
@ -272,6 +272,7 @@ in
|
||||||
nginx-variants = handleTest ./nginx-variants.nix {};
|
nginx-variants = handleTest ./nginx-variants.nix {};
|
||||||
nix-ssh-serve = handleTest ./nix-ssh-serve.nix {};
|
nix-ssh-serve = handleTest ./nix-ssh-serve.nix {};
|
||||||
nixos-generate-config = handleTest ./nixos-generate-config.nix {};
|
nixos-generate-config = handleTest ./nixos-generate-config.nix {};
|
||||||
|
nomad = handleTest ./nomad.nix {};
|
||||||
novacomd = handleTestOn ["x86_64-linux"] ./novacomd.nix {};
|
novacomd = handleTestOn ["x86_64-linux"] ./novacomd.nix {};
|
||||||
nsd = handleTest ./nsd.nix {};
|
nsd = handleTest ./nsd.nix {};
|
||||||
nzbget = handleTest ./nzbget.nix {};
|
nzbget = handleTest ./nzbget.nix {};
|
||||||
|
|
53
nixos/tests/nomad.nix
Normal file
53
nixos/tests/nomad.nix
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
import ./make-test-python.nix (
|
||||||
|
{ lib, ... }: {
|
||||||
|
name = "nomad";
|
||||||
|
nodes = {
|
||||||
|
server = { pkgs, lib, ... }: {
|
||||||
|
networking = {
|
||||||
|
interfaces.eth1.ipv4.addresses = lib.mkOverride 0 [{
|
||||||
|
address = "192.168.1.1";
|
||||||
|
prefixLength = 16;
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.etc."nomad.custom.json".source =
|
||||||
|
(pkgs.formats.json { }).generate "nomad.custom.json" {
|
||||||
|
region = "universe";
|
||||||
|
datacenter = "earth";
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nomad = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
server = {
|
||||||
|
enabled = true;
|
||||||
|
bootstrap_expect = 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
extraSettingsPaths = [ "/etc/nomad.custom.json" ];
|
||||||
|
enableDocker = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
server.wait_for_unit("nomad.service")
|
||||||
|
|
||||||
|
# wait for healthy server
|
||||||
|
server.wait_until_succeeds(
|
||||||
|
"[ $(nomad operator raft list-peers | grep true | wc -l) == 1 ]"
|
||||||
|
)
|
||||||
|
|
||||||
|
# wait for server liveness
|
||||||
|
server.succeed("[ $(nomad server members | grep -o alive | wc -l) == 1 ]")
|
||||||
|
|
||||||
|
# check the region
|
||||||
|
server.succeed("nomad server members | grep -o universe")
|
||||||
|
|
||||||
|
# check the datacenter
|
||||||
|
server.succeed("[ $(nomad server members | grep -o earth | wc -l) == 1 ]")
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
)
|
Loading…
Reference in a new issue