summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/admin
diff options
context:
space:
mode:
authorAneesh Agrawal <aneeshusa@gmail.com>2017-01-13 15:00:49 -0500
committerAneesh Agrawal <aneeshusa@gmail.com>2017-05-10 21:26:02 -0400
commite22ccad978eb1331360331eaa45f7ce41a44806a (patch)
treee11845b6837d43b48d6f580b4d6fd0bd74aa3fed /nixos/modules/services/admin
parent6fc56fa8d4c7ba259e44080c1c34a0d74a276eb2 (diff)
salt: Add minion service module
Diffstat (limited to 'nixos/modules/services/admin')
-rw-r--r--nixos/modules/services/admin/salt/minion.nix52
1 files changed, 52 insertions, 0 deletions
diff --git a/nixos/modules/services/admin/salt/minion.nix b/nixos/modules/services/admin/salt/minion.nix
new file mode 100644
index 000000000000..150e2ffa4031
--- /dev/null
+++ b/nixos/modules/services/admin/salt/minion.nix
@@ -0,0 +1,52 @@
+{ config, pkgs, lib, ... }:
+
+with lib;
+
+let
+
+ cfg = config.services.salt.minion;
+
+ fullConfig = lib.recursiveUpdate {
+ # Provide defaults for some directories to allow an immutable config dir
+ # NOTE: the config dir being immutable prevents `minion_id` caching
+
+ # Default is equivalent to /etc/salt/minion.d/*.conf
+ default_include = "/var/lib/salt/minion.d/*.conf";
+ # Default is in /etc/salt/pki/minion
+ pki_dir = "/var/lib/salt/pki/minion";
+ } cfg.configuration;
+ configDir = pkgs.writeTextDir "minion" (builtins.toJSON fullConfig);
+
+in
+
+{
+ options = {
+ services.salt.minion = {
+ enable = mkEnableOption "Salt minion service";
+ configuration = mkOption {
+ type = types.attrs;
+ default = {};
+ description = "Salt minion configuration as Nix attribute set.";
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+ environment.systemPackages = with pkgs; [ salt ];
+ systemd.services.salt-minion = {
+ description = "Salt Minion";
+ wantedBy = [ "multi-user.target" ];
+ after = [ "network.target" ];
+ path = with pkgs; [
+ utillinux
+ ];
+ serviceConfig = {
+ ExecStart = "${pkgs.salt}/bin/salt-minion --config-dir=${configDir}";
+ LimitNOFILE = 8192;
+ Type = "notify";
+ NotifyAccess = "all";
+ };
+ };
+ };
+}
+