2017-01-13 20:00:49 +00:00
|
|
|
{ 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;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.salt.minion = {
|
|
|
|
enable = mkEnableOption "Salt minion service";
|
|
|
|
configuration = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = {};
|
2017-05-11 07:12:04 +01:00
|
|
|
description = ''
|
|
|
|
Salt minion configuration as Nix attribute set.
|
2017-05-15 04:32:45 +01:00
|
|
|
See <link xlink:href="https://docs.saltstack.com/en/latest/ref/configuration/minion.html"/>
|
|
|
|
for details.
|
2017-05-11 07:12:04 +01:00
|
|
|
'';
|
2017-01-13 20:00:49 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2017-05-15 04:29:32 +01:00
|
|
|
environment = {
|
|
|
|
# Set this up in /etc/salt/minion so `salt-call`, etc. work.
|
|
|
|
# The alternatives are
|
|
|
|
# - passing --config-dir to all salt commands, not just the minion unit,
|
|
|
|
# - setting aglobal environment variable.
|
|
|
|
etc."salt/minion".source = pkgs.writeText "minion" (
|
|
|
|
builtins.toJSON fullConfig
|
|
|
|
);
|
|
|
|
systemPackages = with pkgs; [ salt ];
|
|
|
|
};
|
2017-01-13 20:00:49 +00:00
|
|
|
systemd.services.salt-minion = {
|
|
|
|
description = "Salt Minion";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
path = with pkgs; [
|
|
|
|
utillinux
|
|
|
|
];
|
|
|
|
serviceConfig = {
|
2017-05-15 04:29:32 +01:00
|
|
|
ExecStart = "${pkgs.salt}/bin/salt-minion";
|
2017-01-13 20:00:49 +00:00
|
|
|
LimitNOFILE = 8192;
|
|
|
|
Type = "notify";
|
|
|
|
NotifyAccess = "all";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|