diff options
author | wmertens <Wout.Mertens@gmail.com> | 2014-12-19 08:10:07 +0100 |
---|---|---|
committer | wmertens <Wout.Mertens@gmail.com> | 2014-12-19 08:10:07 +0100 |
commit | a8c726da560f0ae81e08b96c9770cd43860870ee (patch) | |
tree | 70752be04ecf2e74313b9ce54cd56a99b380e6f3 /nixos | |
parent | 4b65f5365210111a6a3d3bcf69401df324423f2d (diff) | |
parent | c47cefd05e8ed64b63e589eb8f572eb0a7a0e8f2 (diff) | |
download | nixlib-a8c726da560f0ae81e08b96c9770cd43860870ee.tar nixlib-a8c726da560f0ae81e08b96c9770cd43860870ee.tar.gz nixlib-a8c726da560f0ae81e08b96c9770cd43860870ee.tar.bz2 nixlib-a8c726da560f0ae81e08b96c9770cd43860870ee.tar.lz nixlib-a8c726da560f0ae81e08b96c9770cd43860870ee.tar.xz nixlib-a8c726da560f0ae81e08b96c9770cd43860870ee.tar.zst nixlib-a8c726da560f0ae81e08b96c9770cd43860870ee.zip |
Merge pull request #5378 from benley/mesos
mesos-slave: add config option for slave attributes
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/misc/mesos-slave.nix | 57 | ||||
-rw-r--r-- | nixos/tests/mesos.nix | 4 |
2 files changed, 43 insertions, 18 deletions
diff --git a/nixos/modules/services/misc/mesos-slave.nix b/nixos/modules/services/misc/mesos-slave.nix index d89531f7e909..26fb3fdb00c9 100644 --- a/nixos/modules/services/misc/mesos-slave.nix +++ b/nixos/modules/services/misc/mesos-slave.nix @@ -5,6 +5,13 @@ with lib; let cfg = config.services.mesos.slave; + mkAttributes = + attrs: concatStringsSep ";" (mapAttrsToList + (k: v: "${k}:${v}") + (filterAttrs (k: v: v != null) attrs)); + attribsArg = optionalString (cfg.attributes != {}) + "--attributes=${mkAttributes cfg.attributes}"; + in { options.services.mesos = { @@ -31,9 +38,9 @@ in { }; withHadoop = mkOption { - description = "Add the HADOOP_HOME to the slave."; - default = false; - type = types.bool; + description = "Add the HADOOP_HOME to the slave."; + default = false; + type = types.bool; }; workDir = mkOption { @@ -44,10 +51,10 @@ in { extraCmdLineOptions = mkOption { description = '' - Extra command line options for Mesos Slave. + Extra command line options for Mesos Slave. - See https://mesos.apache.org/documentation/latest/configuration/ - ''; + See https://mesos.apache.org/documentation/latest/configuration/ + ''; default = [ "" ]; type = types.listOf types.string; example = [ "--gc_delay=3days" ]; @@ -62,6 +69,19 @@ in { type = types.str; }; + attributes = mkOption { + description = '' + Machine attributes for the slave instance. + + Use caution when changing this; you may need to manually reset slave + metadata before the slave can re-register. + ''; + default = {}; + type = types.attrsOf types.str; + example = { rack = "aa"; + host = "aabc123"; + os = "nixos"; }; + }; }; }; @@ -74,20 +94,21 @@ in { after = [ "network-interfaces.target" ]; environment.MESOS_CONTAINERIZERS = "docker,mesos"; serviceConfig = { - ExecStart = '' - ${pkgs.mesos}/bin/mesos-slave \ - --port=${toString cfg.port} \ - --master=${cfg.master} \ - ${optionalString cfg.withHadoop "--hadoop-home=${pkgs.hadoop}"} \ - --work_dir=${cfg.workDir} \ - --logging_level=${cfg.logLevel} \ - --docker=${pkgs.docker}/libexec/docker/docker \ - ${toString cfg.extraCmdLineOptions} - ''; - PermissionsStartOnly = true; + ExecStart = '' + ${pkgs.mesos}/bin/mesos-slave \ + --port=${toString cfg.port} \ + --master=${cfg.master} \ + ${optionalString cfg.withHadoop "--hadoop-home=${pkgs.hadoop}"} \ + ${attribsArg} \ + --work_dir=${cfg.workDir} \ + --logging_level=${cfg.logLevel} \ + --docker=${pkgs.docker}/libexec/docker/docker \ + ${toString cfg.extraCmdLineOptions} + ''; + PermissionsStartOnly = true; }; preStart = '' - mkdir -m 0700 -p ${cfg.workDir} + mkdir -m 0700 -p ${cfg.workDir} ''; }; }; diff --git a/nixos/tests/mesos.nix b/nixos/tests/mesos.nix index 4fc02d1cd3ff..040f613c5966 100644 --- a/nixos/tests/mesos.nix +++ b/nixos/tests/mesos.nix @@ -8,6 +8,10 @@ import ./make-test.nix { slave = { enable = true; master = "zk://localhost:2181/mesos"; + attributes = { + tag1 = "foo"; + tag2 = "bar"; + }; }; master = { enable = true; |