]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/system/backup-2.nix
Add openldap replication
[perso/Immae/Config/Nix.git] / modules / private / system / backup-2.nix
1 { privateFiles }:
2 { config, pkgs, myconfig, resources, ... }:
3 {
4 boot.kernelPackages = pkgs.linuxPackages_latest;
5 _module.args.privateFiles = privateFiles;
6 _module.args.hostFQDN = "backup-2.v.immae.eu";
7 imports = builtins.attrValues (import ../..);
8
9 deployment = {
10 targetEnv = "hetznerCloud";
11 hetznerCloud = {
12 authToken = myconfig.env.hetznerCloud.authToken;
13 datacenter = "hel1-dc2";
14 location ="hel1";
15 serverType = "cx11";
16 };
17 };
18
19 fileSystems = {
20 "/backup2" = {
21 fsType = "ext4";
22 device = "UUID=b9425333-f567-435d-94d8-b26c22d93426";
23 };
24 };
25
26 networking = {
27 firewall.enable = true;
28 interfaces."ens3".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
29 (n: ips: { address = ips.ip4; prefixLength = 32; })
30 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") myconfig.env.servers.backup-2.ips);
31 interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
32 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
33 myconfig.env.servers.backup-2.ips);
34
35 defaultMailServer = {
36 directDelivery = true;
37 hostName = "eldiron.immae.eu:25";
38 useTLS = true;
39 useSTARTTLS = true;
40 root = "postmaster@immae.eu";
41 };
42 };
43
44 services.rsyncBackup = {
45 mountpoint = "/backup2";
46 mailto = myconfig.env.rsync_backup.mailto;
47 profiles = myconfig.env.rsync_backup.profiles;
48 ssh_key_public = myconfig.env.rsync_backup.ssh_key.public;
49 ssh_key_private = myconfig.env.rsync_backup.ssh_key.private;
50 };
51
52 myServices.monitoring.enable = true;
53 myServices.databasesReplication = {
54 postgresql = {
55 enable = true;
56 base = "/backup2";
57 hosts = {
58 eldiron = {
59 slot = "backup_2";
60 connection = "postgresql://backup-2:${myconfig.env.ldap.backup-2.password}@eldiron.immae.eu";
61 };
62 };
63 };
64 mariadb = {
65 enable = true;
66 base = "/backup2";
67 hosts = {
68 eldiron = {
69 serverId = 2;
70 # mysql resolves "backup-2" host and checks the ip, but uses /etc/hosts which only contains ip4
71 host = myconfig.env.servers.eldiron.ips.main.ip4;
72 port = "3306";
73 user = "backup-2";
74 password = myconfig.env.ldap.backup-2.password;
75 dumpUser = "root";
76 dumpPassword = myconfig.env.databases.mysql.systemUsers.root;
77 };
78 };
79 };
80 redis = {
81 enable = true;
82 base = "/backup2";
83 hosts = {
84 eldiron = {
85 host = "127.0.0.1";
86 port = "16379";
87 };
88 };
89 };
90 openldap = {
91 enable = true;
92 base = "/backup2";
93 hosts = {
94 eldiron = {
95 url = "ldaps://${myconfig.env.ldap.host}:636";
96 dn = myconfig.env.ldap.replication_dn;
97 password = myconfig.env.ldap.replication_pw;
98 base = myconfig.env.ldap.base;
99 };
100 };
101 };
102 };
103
104 # This value determines the NixOS release with which your system is
105 # to be compatible, in order to avoid breaking some software such as
106 # database servers. You should change this only after NixOS release
107 # notes say you should.
108 # https://nixos.org/nixos/manual/release-notes.html
109 system.stateVersion = "19.03"; # Did you read the comment?
110 }