2014-08-26 18:56:54 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.mesos.master;
|
2014-12-01 15:57:17 +00:00
|
|
|
|
2014-08-26 18:56:54 +00:00
|
|
|
in {
|
|
|
|
|
|
|
|
options.services.mesos = {
|
2014-12-01 15:57:17 +00:00
|
|
|
|
2014-08-26 18:56:54 +00:00
|
|
|
master = {
|
|
|
|
enable = mkOption {
|
|
|
|
description = "Whether to enable the Mesos Master.";
|
|
|
|
default = false;
|
2015-06-15 16:10:26 +00:00
|
|
|
type = types.bool;
|
2014-08-26 18:56:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
description = "Mesos Master port";
|
|
|
|
default = 5050;
|
|
|
|
type = types.int;
|
|
|
|
};
|
|
|
|
|
|
|
|
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 15:57:17 +00:00
|
|
|
|
2014-08-26 18:56:54 +00:00
|
|
|
workDir = mkOption {
|
|
|
|
description = "The Mesos work directory.";
|
|
|
|
default = "/var/lib/mesos/master";
|
|
|
|
type = types.str;
|
|
|
|
};
|
2014-12-01 15:57:17 +00:00
|
|
|
|
2014-08-26 18:56:54 +00:00
|
|
|
extraCmdLineOptions = mkOption {
|
|
|
|
description = ''
|
2015-05-10 20:38:19 +00:00
|
|
|
Extra command line options for Mesos Master.
|
2014-12-01 15:57:17 +00:00
|
|
|
|
2015-05-10 20:38:19 +00:00
|
|
|
See https://mesos.apache.org/documentation/latest/configuration/
|
|
|
|
'';
|
2014-08-26 18:56:54 +00:00
|
|
|
default = [ "" ];
|
2015-06-15 16:18:46 +00:00
|
|
|
type = types.listOf types.str;
|
2014-08-26 18:56:54 +00:00
|
|
|
example = [ "--credentials=VALUE" ];
|
|
|
|
};
|
2014-12-01 15:57:17 +00:00
|
|
|
|
2014-08-26 18:56:54 +00: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 15:57:17 +00:00
|
|
|
|
2014-08-26 18:56:54 +00:00
|
|
|
If 0 will fall back to --registry=in_memory.
|
|
|
|
'';
|
|
|
|
default = 0;
|
|
|
|
type = types.int;
|
|
|
|
};
|
2014-12-01 15:57:17 +00:00
|
|
|
|
2014-08-26 18:56:54 +00:00
|
|
|
logLevel = mkOption {
|
|
|
|
description = ''
|
|
|
|
The logging level used. Possible values:
|
|
|
|
'INFO', 'WARNING', 'ERROR'
|
|
|
|
'';
|
|
|
|
default = "INFO";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.mesos-master = {
|
|
|
|
description = "Mesos Master";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2016-09-10 18:12:12 +00:00
|
|
|
after = [ "network.target" ];
|
2014-08-26 18:56:54 +00:00
|
|
|
serviceConfig = {
|
2015-05-10 20:38:19 +00:00
|
|
|
ExecStart = ''
|
|
|
|
${pkgs.mesos}/bin/mesos-master \
|
|
|
|
--port=${toString cfg.port} \
|
2015-05-10 22:13:00 +00:00
|
|
|
${if cfg.quorum == 0
|
|
|
|
then "--registry=in_memory"
|
|
|
|
else "--zk=${cfg.zk} --registry=replicated_log --quorum=${toString cfg.quorum}"} \
|
2015-05-10 20:38:19 +00:00
|
|
|
--work_dir=${cfg.workDir} \
|
|
|
|
--logging_level=${cfg.logLevel} \
|
|
|
|
${toString cfg.extraCmdLineOptions}
|
|
|
|
'';
|
|
|
|
Restart = "on-failure";
|
|
|
|
PermissionsStartOnly = true;
|
2014-08-26 18:56:54 +00:00
|
|
|
};
|
|
|
|
preStart = ''
|
2015-05-10 20:38:19 +00:00
|
|
|
mkdir -m 0700 -p ${cfg.workDir}
|
2014-08-26 18:56:54 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2014-12-01 15:57:17 +00:00
|
|
|
|
2014-08-26 18:56:54 +00:00
|
|
|
}
|
|
|
|
|