aboutsummaryrefslogtreecommitdiff
path: root/systems/eldiron/databases/default.nix
blob: d8d3048787b64bd76d1551e07f7e16aaf876d58e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{ lib, config, secrets, ... }:
let
  cfg = config.myServices.databases;
in
{
  options.myServices = {
    databases.enable = lib.mkEnableOption "my databases service";
  };

  config.myServices.dns.zones."immae.eu".subdomains.db-1 = lib.mkIf cfg.enable (with config.myServices.dns.helpers; ips servers.eldiron.ips.main);
  config.myServices.databases = lib.mkIf cfg.enable {

    mariadb = {
      enable = true;
      ldapConfig = {
        inherit (config.myEnv.ldap) host base;
        inherit (config.myEnv.databases.mysql.pam) dn filter password;
      };
      replicationLdapConfig = {
        inherit (config.myEnv.ldap) host base;
        inherit (config.myEnv.servers.eldiron.ldap) dn password;
      };
      credentials.root = config.myEnv.databases.mysql.systemUsers.root;
    };

    openldap = {
      accessFile = secrets.ldap-conf;
      baseDn = config.myEnv.ldap.base;
      rootDn = config.myEnv.ldap.root_dn;
      rootPw = config.myEnv.ldap.root_pw;
      enable = true;
    };

    postgresql = {
      ldapConfig = {
        inherit (config.myEnv.ldap) host base;
        inherit (config.myEnv.databases.postgresql.pam) dn filter password;
      };
      replicationLdapConfig = {
        inherit (config.myEnv.ldap) host base;
        inherit (config.myEnv.servers.eldiron.ldap) dn password;
      };
      authorizedHosts = {
      };
      replicationHosts = {
        backup-2 = {
          ip4 = config.myEnv.servers.backup-2.ips.main.ip4;
          ip6 = config.myEnv.servers.backup-2.ips.main.ip6;
        };
      };
      enable = true;
    };

    redis.enable = true;
  };
}