at 17.09-beta 3.3 kB view raw
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 ip = mkOption { 20 description = "IP address to listen on."; 21 default = "0.0.0.0"; 22 type = types.str; 23 }; 24 25 port = mkOption { 26 description = "Mesos Master port"; 27 default = 5050; 28 type = types.int; 29 }; 30 31 advertiseIp = mkOption { 32 description = "IP address advertised to reach this master."; 33 default = null; 34 type = types.nullOr types.str; 35 }; 36 37 advertisePort = mkOption { 38 description = "Port advertised to reach this Mesos master."; 39 default = null; 40 type = types.nullOr types.int; 41 }; 42 43 zk = mkOption { 44 description = '' 45 ZooKeeper URL (used for leader election amongst masters). 46 May be one of: 47 zk://host1:port1,host2:port2,.../mesos 48 zk://username:password@host1:port1,host2:port2,.../mesos 49 ''; 50 type = types.str; 51 }; 52 53 workDir = mkOption { 54 description = "The Mesos work directory."; 55 default = "/var/lib/mesos/master"; 56 type = types.str; 57 }; 58 59 extraCmdLineOptions = mkOption { 60 description = '' 61 Extra command line options for Mesos Master. 62 63 See https://mesos.apache.org/documentation/latest/configuration/ 64 ''; 65 default = [ "" ]; 66 type = types.listOf types.str; 67 example = [ "--credentials=VALUE" ]; 68 }; 69 70 quorum = mkOption { 71 description = '' 72 The size of the quorum of replicas when using 'replicated_log' based 73 registry. It is imperative to set this value to be a majority of 74 masters i.e., quorum > (number of masters)/2. 75 76 If 0 will fall back to --registry=in_memory. 77 ''; 78 default = 0; 79 type = types.int; 80 }; 81 82 logLevel = mkOption { 83 description = '' 84 The logging level used. Possible values: 85 'INFO', 'WARNING', 'ERROR' 86 ''; 87 default = "INFO"; 88 type = types.str; 89 }; 90 91 }; 92 93 94 }; 95 96 97 config = mkIf cfg.enable { 98 systemd.services.mesos-master = { 99 description = "Mesos Master"; 100 wantedBy = [ "multi-user.target" ]; 101 after = [ "network.target" ]; 102 serviceConfig = { 103 ExecStart = '' 104 ${pkgs.mesos}/bin/mesos-master \ 105 --ip=${cfg.ip} \ 106 --port=${toString cfg.port} \ 107 ${optionalString (cfg.advertiseIp != null) "--advertise_ip=${cfg.advertiseIp}"} \ 108 ${optionalString (cfg.advertisePort != null) "--advertise_port=${toString cfg.advertisePort}"} \ 109 ${if cfg.quorum == 0 110 then "--registry=in_memory" 111 else "--zk=${cfg.zk} --registry=replicated_log --quorum=${toString cfg.quorum}"} \ 112 --work_dir=${cfg.workDir} \ 113 --logging_level=${cfg.logLevel} \ 114 ${toString cfg.extraCmdLineOptions} 115 ''; 116 Restart = "on-failure"; 117 PermissionsStartOnly = true; 118 }; 119 preStart = '' 120 mkdir -m 0700 -p ${cfg.workDir} 121 ''; 122 }; 123 }; 124 125} 126