nixpkgs/nixos/modules/services/misc/mesos-master.nix

126 lines
3.2 KiB
Nix
Raw Normal View History

2014-08-26 20:56:54 +02:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.mesos.master;
2014-12-01 16:57:17 +01:00
2014-08-26 20:56:54 +02:00
in {
options.services.mesos = {
2014-12-01 16:57:17 +01:00
2014-08-26 20:56:54 +02:00
master = {
enable = mkOption {
description = "Whether to enable the Mesos Master.";
default = false;
2015-06-15 18:10:26 +02:00
type = types.bool;
2014-08-26 20:56:54 +02:00
};
2016-12-28 06:19:51 +01:00
ip = mkOption {
description = "IP address to listen on.";
default = "0.0.0.0";
type = types.str;
};
2014-08-26 20:56:54 +02:00
port = mkOption {
description = "Mesos Master port";
default = 5050;
type = types.int;
};
2016-12-28 06:19:51 +01:00
advertiseIp = mkOption {
description = "IP address advertised to reach this master.";
default = null;
type = types.nullOr types.str;
};
advertisePort = mkOption {
description = "Port advertised to reach this Mesos master.";
default = null;
type = types.nullOr types.int;
};
2014-08-26 20:56:54 +02:00
zk = mkOption {
description = ''
ZooKeeper URL (used for leader election amongst masters).
May be one of:
zk://host1:port1,host2:port2,.../mesos
zk://username:password@host1:port1,host2:port2,.../mesos
'';
type = types.str;
};
2014-12-01 16:57:17 +01:00
2014-08-26 20:56:54 +02:00
workDir = mkOption {
description = "The Mesos work directory.";
default = "/var/lib/mesos/master";
type = types.str;
};
2014-12-01 16:57:17 +01:00
2014-08-26 20:56:54 +02:00
extraCmdLineOptions = mkOption {
description = ''
Extra command line options for Mesos Master.
2014-12-01 16:57:17 +01:00
See https://mesos.apache.org/documentation/latest/configuration/
'';
2014-08-26 20:56:54 +02:00
default = [ "" ];
2015-06-15 18:18:46 +02:00
type = types.listOf types.str;
2014-08-26 20:56:54 +02:00
example = [ "--credentials=VALUE" ];
};
2014-12-01 16:57:17 +01:00
2014-08-26 20:56:54 +02:00
quorum = mkOption {
description = ''
The size of the quorum of replicas when using 'replicated_log' based
registry. It is imperative to set this value to be a majority of
masters i.e., quorum > (number of masters)/2.
2014-12-01 16:57:17 +01:00
2014-08-26 20:56:54 +02:00
If 0 will fall back to --registry=in_memory.
'';
default = 0;
type = types.int;
};
2014-12-01 16:57:17 +01:00
2014-08-26 20:56:54 +02:00
logLevel = mkOption {
description = ''
The logging level used. Possible values:
'INFO', 'WARNING', 'ERROR'
'';
default = "INFO";
type = types.str;
};
};
};
config = mkIf cfg.enable {
systemd.tmpfiles.rules = [
"d '${cfg.workDir}' 0700 - - - -"
];
2014-08-26 20:56:54 +02:00
systemd.services.mesos-master = {
description = "Mesos Master";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
2014-08-26 20:56:54 +02:00
serviceConfig = {
ExecStart = ''
${pkgs.mesos}/bin/mesos-master \
2016-12-28 06:19:51 +01:00
--ip=${cfg.ip} \
--port=${toString cfg.port} \
2016-12-28 06:19:51 +01:00
${optionalString (cfg.advertiseIp != null) "--advertise_ip=${cfg.advertiseIp}"} \
${optionalString (cfg.advertisePort != null) "--advertise_port=${toString cfg.advertisePort}"} \
${if cfg.quorum == 0
then "--registry=in_memory"
else "--zk=${cfg.zk} --registry=replicated_log --quorum=${toString cfg.quorum}"} \
--work_dir=${cfg.workDir} \
--logging_level=${cfg.logLevel} \
${toString cfg.extraCmdLineOptions}
'';
Restart = "on-failure";
2014-08-26 20:56:54 +02:00
};
};
};
2014-12-01 16:57:17 +01:00
2014-08-26 20:56:54 +02:00
}