2020-04-24 23:36:52 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.salt.master;
|
|
|
|
|
|
|
|
fullConfig = lib.recursiveUpdate {
|
|
|
|
# Provide defaults for some directories to allow an immutable config dir
|
|
|
|
|
|
|
|
# Default is equivalent to /etc/salt/master.d/*.conf
|
|
|
|
default_include = "/var/lib/salt/master.d/*.conf";
|
|
|
|
# Default is in /etc/salt/pki/master
|
|
|
|
pki_dir = "/var/lib/salt/pki/master";
|
|
|
|
} cfg.configuration;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.salt.master = {
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "Salt master service");
|
2020-04-24 23:36:52 +00:00
|
|
|
configuration = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = {};
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Salt master configuration as Nix attribute set.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment = {
|
|
|
|
# Set this up in /etc/salt/master so `salt`, `salt-key`, etc. work.
|
|
|
|
# The alternatives are
|
|
|
|
# - passing --config-dir to all salt commands, not just the master unit,
|
|
|
|
# - setting a global environment variable,
|
|
|
|
etc."salt/master".source = pkgs.writeText "master" (
|
|
|
|
builtins.toJSON fullConfig
|
|
|
|
);
|
|
|
|
systemPackages = with pkgs; [ salt ];
|
|
|
|
};
|
|
|
|
systemd.services.salt-master = {
|
|
|
|
description = "Salt Master";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
path = with pkgs; [
|
2020-11-24 20:58:05 +00:00
|
|
|
util-linux # for dmesg
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.salt}/bin/salt-master";
|
|
|
|
LimitNOFILE = 16384;
|
|
|
|
Type = "notify";
|
|
|
|
NotifyAccess = "all";
|
|
|
|
};
|
|
|
|
restartTriggers = [
|
|
|
|
config.environment.etc."salt/master".source
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-10-27 00:29:36 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [ Flakebi ];
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|