1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.mesos.master; 7 8in { 9 10 options.services.mesos = { 11 12 master = { 13 enable = mkOption { 14 description = "Whether to enable the Mesos Master."; 15 default = false; 16 type = types.bool; 17 }; 18 19 port = mkOption { 20 description = "Mesos Master port"; 21 default = 5050; 22 type = types.int; 23 }; 24 25 zk = mkOption { 26 description = '' 27 ZooKeeper URL (used for leader election amongst masters). 28 May be one of: 29 zk://host1:port1,host2:port2,.../mesos 30 zk://username:password@host1:port1,host2:port2,.../mesos 31 ''; 32 type = types.str; 33 }; 34 35 workDir = mkOption { 36 description = "The Mesos work directory."; 37 default = "/var/lib/mesos/master"; 38 type = types.str; 39 }; 40 41 extraCmdLineOptions = mkOption { 42 description = '' 43 Extra command line options for Mesos Master. 44 45 See https://mesos.apache.org/documentation/latest/configuration/ 46 ''; 47 default = [ "" ]; 48 type = types.listOf types.str; 49 example = [ "--credentials=VALUE" ]; 50 }; 51 52 quorum = mkOption { 53 description = '' 54 The size of the quorum of replicas when using 'replicated_log' based 55 registry. It is imperative to set this value to be a majority of 56 masters i.e., quorum > (number of masters)/2. 57 58 If 0 will fall back to --registry=in_memory. 59 ''; 60 default = 0; 61 type = types.int; 62 }; 63 64 logLevel = mkOption { 65 description = '' 66 The logging level used. Possible values: 67 'INFO', 'WARNING', 'ERROR' 68 ''; 69 default = "INFO"; 70 type = types.str; 71 }; 72 73 }; 74 75 76 }; 77 78 79 config = mkIf cfg.enable { 80 systemd.services.mesos-master = { 81 description = "Mesos Master"; 82 wantedBy = [ "multi-user.target" ]; 83 after = [ "network-interfaces.target" ]; 84 serviceConfig = { 85 ExecStart = '' 86 ${pkgs.mesos}/bin/mesos-master \ 87 --port=${toString cfg.port} \ 88 ${if cfg.quorum == 0 89 then "--registry=in_memory" 90 else "--zk=${cfg.zk} --registry=replicated_log --quorum=${toString cfg.quorum}"} \ 91 --work_dir=${cfg.workDir} \ 92 --logging_level=${cfg.logLevel} \ 93 ${toString cfg.extraCmdLineOptions} 94 ''; 95 Restart = "on-failure"; 96 PermissionsStartOnly = true; 97 }; 98 preStart = '' 99 mkdir -m 0700 -p ${cfg.workDir} 100 ''; 101 }; 102 }; 103 104} 105