]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Move databases config to new secrets
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 25 Apr 2019 00:18:11 +0000 (02:18 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 25 Apr 2019 00:18:11 +0000 (02:18 +0200)
nixops/modules/databases/mysql.nix
nixops/modules/databases/openldap.nix
nixops/modules/databases/postgresql.nix

index 95de9721ab3e6aff69a588452b875ba83759e1cb..a9ca8d326d1db8df00d21419c2586cdb7569af59 100644 (file)
@@ -52,9 +52,9 @@ in {
       '';
     };
 
-    deployment.keys = {
-      mysqldump = {
-        destDir = "/run/keys/mysql";
+    mySecrets.keys = [
+      {
+        dest = "mysql/mysqldump";
         permissions = "0400";
         user = "root";
         group = "root";
@@ -63,9 +63,9 @@ in {
           user = root
           password = ${myconfig.env.databases.mysql.systemUsers.root}
         '';
-      };
-      mysql-pam = {
-        destDir = "/run/keys/mysql";
+      }
+      {
+        dest = "mysql/pam";
         permissions = "0400";
         user = "mysql";
         group = "mysql";
@@ -77,14 +77,14 @@ in {
           pam_filter ${filter}
           ssl start_tls
           '';
-      };
-    };
+      }
+    ];
 
     services.cron = {
       enable = true;
       systemCronJobs = [
         ''
-          30 1,13 * * * root ${pkgs.mariadb}/bin/mysqldump --defaults-file=/run/keys/mysql/mysqldump --all-databases > /var/lib/mysql/backup.sql
+          30 1,13 * * * root ${pkgs.mariadb}/bin/mysqldump --defaults-file=/var/secrets/mysql/mysqldump --all-databases > /var/lib/mysql/backup.sql
         ''
       ];
     };
@@ -96,8 +96,8 @@ in {
         name = "mysql";
         text = ''
           # https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/
-          auth    required ${pam_ldap} config=/run/keys/mysql/mysql-pam
-          account required ${pam_ldap} config=/run/keys/mysql/mysql-pam
+          auth    required ${pam_ldap} config=/var/secrets/mysql/pam
+          account required ${pam_ldap} config=/var/secrets/mysql/pam
           '';
       }
     ];
index 7ed4bc090782dcdc4298d362c11ae8891d6bdc2f..a447ccc8484d1a13ef40f5c3d5b3632d3634b001 100644 (file)
@@ -29,7 +29,7 @@ let
       database        hdb
       suffix          "${myconfig.env.ldap.base}"
       rootdn          "${myconfig.env.ldap.root_dn}"
-      include         /run/keys/ldap/ldap-password
+      include         /var/secrets/ldap/password
       directory       /var/lib/openldap
       overlay         memberof
 
@@ -41,7 +41,7 @@ let
       #TLSCipherSuite        DEFAULT
 
       sasl-host kerberos.immae.eu
-      include /run/keys/ldap/ldap-access
+      include /var/secrets/ldap/access
       '';
 in {
   options.services.myDatabases = {
@@ -56,22 +56,22 @@ in {
   };
 
   config = lib.mkIf cfg.enable {
-    deployment.keys = {
-      ldap-password = {
-        destDir = "/run/keys/ldap";
+    mySecrets.keys = [
+       {
+        dest = "ldap/password";
         permissions = "0400";
         user = "openldap";
         group = "openldap";
         text = "rootpw          ${myconfig.env.ldap.root_pw}";
-      };
-      ldap-access = {
-        destDir = "/run/keys/ldap";
+      }
+      {
+        dest = "ldap/access ";
         permissions = "0400";
         user = "openldap";
         group = "openldap";
         text = builtins.readFile "${myconfig.privateFiles}/ldap.conf";
-      };
-    };
+      }
+    ];
     users.users.openldap.extraGroups = [ "keys" ];
     networking.firewall.allowedTCPPorts = [ 636 389 ];
 
index 7e2f4e665fc861a3570b15b9e38f95e4b3c095c7..62e9e34889eddcec1b62150262a80a32f49a154b 100644 (file)
@@ -77,9 +77,9 @@ in {
       '';
     };
 
-    deployment.keys = {
-      postgresql-pam = {
-        destDir = "/run/keys/postgresql";
+    mySecrets.keys = [
+      {
+        dest = "postgresql/pam";
         permissions = "0400";
         group = "postgres";
         user = "postgres";
@@ -91,9 +91,9 @@ in {
           pam_filter ${filter}
           ssl start_tls
         '';
-      };
-      postgresql-pam_replication = {
-        destDir = "/run/keys/postgresql";
+      }
+      {
+        dest = "postgresql/pam_replication";
         permissions = "0400";
         group = "postgres";
         user = "postgres";
@@ -105,8 +105,8 @@ in {
           pam_login_attribute cn
           ssl start_tls
         '';
-      };
-    };
+      }
+    ];
 
     security.pam.services = let
       pam_ldap = "${pkgs.pam_ldap}/lib/security/pam_ldap.so";
@@ -114,15 +114,15 @@ in {
       {
         name = "postgresql";
         text = ''
-          auth    required ${pam_ldap} config=/run/keys/postgresql/postgresql-pam
-          account required ${pam_ldap} config=/run/keys/postgresql/postgresql-pam
+          auth    required ${pam_ldap} config=/var/secrets/postgresql/pam
+          account required ${pam_ldap} config=/var/secrets/postgresql/pam
           '';
       }
       {
         name = "postgresql_replication";
         text = ''
-          auth    required ${pam_ldap} config=/run/keys/postgresql/postgresql-pam_replication
-          account required ${pam_ldap} config=/run/keys/postgresql/postgresql-pam_replication
+          auth    required ${pam_ldap} config=/var/secrets/postgresql/pam_replication
+          account required ${pam_ldap} config=/var/secrets/postgresql/pam_replication
           '';
       }
     ];