feat(storage01): init openbao #327

Merged
thubrecht merged 2 commits from openbao into main 2025-03-11 12:01:05 +01:00
Owner
No description provided.
ecoppens added 2 commits 2025-03-09 00:45:27 +01:00
Signed-off-by: Elias Coppens <elias@dgnum.eu>
feat(machines/storage01): init openbao
Some checks failed
Check meta / check_meta (push) Successful in 14s
Check meta / check_dns (push) Successful in 14s
Run pre-commit on all files / pre-commit (push) Successful in 23s
Check meta / check_meta (pull_request) Successful in 15s
Check workflows / check_workflows (pull_request) Successful in 16s
Check meta / check_dns (pull_request) Successful in 18s
Build all the nodes / netaccess01 (pull_request) Successful in 25s
Build all the nodes / ap01 (pull_request) Successful in 32s
Build all the nodes / netcore01 (pull_request) Successful in 19s
Build all the nodes / netcore02 (pull_request) Successful in 19s
Build all the nodes / build01 (pull_request) Successful in 1m25s
Build all the nodes / bridge01 (pull_request) Successful in 1m27s
Build all the nodes / hypervisor01 (pull_request) Successful in 1m38s
Build all the nodes / hypervisor02 (pull_request) Successful in 1m41s
Build all the nodes / hypervisor03 (pull_request) Successful in 1m43s
Build all the nodes / geo02 (pull_request) Successful in 1m46s
Build all the nodes / geo01 (pull_request) Successful in 1m48s
Build all the nodes / rescue01 (pull_request) Successful in 1m32s
Build all the nodes / storage01 (pull_request) Successful in 1m33s
Build all the nodes / tower01 (pull_request) Successful in 1m30s
Build the shell / build-shell (pull_request) Successful in 25s
Run pre-commit on all files / pre-commit (pull_request) Successful in 23s
Build all the nodes / compute01 (pull_request) Failing after 2m13s
Build all the nodes / vault01 (pull_request) Successful in 1m57s
Build all the nodes / web01 (pull_request) Successful in 2m9s
Build all the nodes / web02 (pull_request) Successful in 1m37s
Build all the nodes / web03 (pull_request) Successful in 1m40s
12c5968ea8
Signed-off-by: Elias Coppens <elias@dgnum.eu>
ecoppens force-pushed openbao from 12c5968ea8 to 3e14576e94 2025-03-09 00:50:47 +01:00 Compare
mdebray approved these changes 2025-03-10 13:44:08 +01:00
Dismissed
mdebray dismissed mdebray's review 2025-03-10 13:44:53 +01:00
Reason:

erreur

mdebray reviewed 2025-03-10 13:45:21 +01:00
@ -0,0 +37,4 @@
enableACME = true;
forceSSL = true;
location."/" = {
proxyPass = "http://127.0.0.1:${toString port}";
Owner

On peut utiliser dgn-web.simpleProxies ici

On peut utiliser `dgn-web.simpleProxies` ici
Author
Owner

:o

:o
ecoppens marked this conversation as resolved
ecoppens force-pushed openbao from 3e14576e94 to 56765c1a79 2025-03-10 20:58:08 +01:00 Compare
ecoppens force-pushed openbao from 56765c1a79 to c9cf7dbbb4 2025-03-10 21:06:07 +01:00 Compare
requested review from mdebray 2025-03-10 21:15:02 +01:00
thubrecht requested changes 2025-03-10 21:22:35 +01:00
Dismissed
@ -0,0 +2,4 @@
#
# SPDX-License-Identifier: EUPL-1.2
_:
Owner

Inutile

Inutile
ecoppens marked this conversation as resolved
@ -0,0 +4,4 @@
_:
let
domain = "vault.dgnum.eu";
Owner
  host = "vault.dgnum.eu";
```nix host = "vault.dgnum.eu"; ```
ecoppens marked this conversation as resolved
@ -0,0 +30,4 @@
'';
};
services.nginx = {
Owner

Comme dit Maurice, tout ce bloc se remplace par :

  dgn-web.simpleProxies.ntfy-sh = {
    inherit host port;
};
Comme dit Maurice, tout ce bloc se remplace par : ```nix dgn-web.simpleProxies.ntfy-sh = { inherit host port; }; ```
ecoppens marked this conversation as resolved
@ -0,0 +4,4 @@
{
imports = [
./module.nix
Owner

???
Si y'a rien de plus que ça met direct le module en default.nix

??? Si y'a rien de plus que ça met direct le module en default.nix
ecoppens marked this conversation as resolved
@ -0,0 +10,4 @@
...
}:
with lib;
Owner

Niet

Niet
ecoppens marked this conversation as resolved
@ -0,0 +14,4 @@
let
cfg = config.services.openbao;
opt = options.services.openbao;
Owner

C'est utilisé uniquement pour mettre config.${opt.storageBackend} à la place de config.storageBackend dans le defaultText d'une option, ça peut être supprimé imo

C'est utilisé uniquement pour mettre `config.${opt.storageBackend}` à la place de `config.storageBackend` dans le defaultText d'une option, ça peut être supprimé imo
ecoppens marked this conversation as resolved
@ -0,0 +16,4 @@
cfg = config.services.openbao;
opt = options.services.openbao;
configFile = pkgs.writeText "openbao.hcl" ''
Owner

Via la documentation,

The format of this file is HCL or JSON.

Donc on va faire du json avec pkgs.formats.json et faire des settings structurés c.f. la RFC42

Via la documentation, > The format of this file is HCL or JSON. Donc on va faire du json avec `pkgs.formats.json` et faire des settings structurés c.f. la RFC42
ecoppens marked this conversation as resolved
@ -0,0 +64,4 @@
services.openbao = {
enable = mkEnableOption "OpenBao daemon";
package = mkOption {
Owner
package = mkPackageOption pkgs "openbao" { };
```nix package = mkPackageOption pkgs "openbao" { }; ```
ecoppens marked this conversation as resolved
@ -0,0 +70,4 @@
description = "OpenBao package";
};
dev = mkOption {
Owner

Je pense pas qu'on en ait besoin.
Si vraiment c'est nécessaire, il y a mkEnableOption qui existe.

Je pense pas qu'on en ait besoin. Si vraiment c'est nécessaire, il y a `mkEnableOption` qui existe.
ecoppens marked this conversation as resolved
@ -0,0 +78,4 @@
'';
};
devRootTokenID = mkOption {
Owner

Same as above

Same as above
ecoppens marked this conversation as resolved
@ -0,0 +93,4 @@
};
tlsCertFile = mkOption {
type = types.nullOr types.str;
Owner

nullOr path

`nullOr path`
ecoppens marked this conversation as resolved
@ -0,0 +100,4 @@
};
tlsKeyFile = mkOption {
type = types.nullOr types.str;
Owner

Pareil

Pareil
ecoppens marked this conversation as resolved
@ -0,0 +172,4 @@
description = "Extra text appended to {file}`vault.hcl`.";
};
extraSettingsPaths = mkOption {
Owner

Puisque la config se fera en JSON, en faisant

systemd.services.openbao = {
  preStart = genJqSecretsReplacementSnippet configFile "${stateDir}/config.json";
  ...
};

les secrets peuvent être indiqués dans la config avec la valeur machin._secret = path avec path qui contient le secret et ça sera remplacé comme il faut.

Puisque la config se fera en JSON, en faisant ``` systemd.services.openbao = { preStart = genJqSecretsReplacementSnippet configFile "${stateDir}/config.json"; ... }; ``` les secrets peuvent être indiqués dans la config avec la valeur `machin._secret = path` avec `path` qui contient le secret et ça sera remplacé comme il faut.
ecoppens marked this conversation as resolved
@ -0,0 +228,4 @@
}
];
users.users.openbao = {
Owner

Pourquoi est-ce qu'on aurait besoin d'un user ? En DynamicUser only ça ne fonctionne pas ?

Pourquoi est-ce qu'on aurait besoin d'un user ? En `DynamicUser` only ça ne fonctionne pas ?
ecoppens marked this conversation as resolved
@ -0,0 +236,4 @@
};
users.groups.openbao.gid = config.ids.gids.vault;
systemd.tmpfiles.rules = optional (
Owner

Ça se fait via StateDirectory et UMask dans l'unit systemd

Ça se fait via `StateDirectory` et `UMask` dans l'unit systemd
ecoppens marked this conversation as resolved
@ -0,0 +252,4 @@
startLimitIntervalSec = 60;
startLimitBurst = 3;
serviceConfig = {
Owner

Pas de DynamicUser ?

Pas de `DynamicUser` ?
ecoppens marked this conversation as resolved
@ -0,0 +255,4 @@
serviceConfig = {
User = "openbao";
Group = "openbao";
ExecStart = "${lib.getExe cfg.package} server ${configOptions}";
Owner
ExecStart = escapeSystemdExecArgs [ ... ];

Et on inline configOptions, avec potentiellement l'ajout d'une option extraArgs qui y sera concaténée.

```nix ExecStart = escapeSystemdExecArgs [ ... ]; ``` Et on inline `configOptions`, avec potentiellement l'ajout d'une option `extraArgs` qui y sera concaténée.
ecoppens marked this conversation as resolved
@ -0,0 +256,4 @@
User = "openbao";
Group = "openbao";
ExecStart = "${lib.getExe cfg.package} server ${configOptions}";
ExecReload = "${pkgs.coreutils}/bin/kill -SIGHUP $MAINPID";
Owner
        ExecReload = "${getExe' pkgs.coreutils "kill"} -SIGHUP $MAINPID"; 
```nix ExecReload = "${getExe' pkgs.coreutils "kill"} -SIGHUP $MAINPID"; ```
ecoppens marked this conversation as resolved
@ -0,0 +259,4 @@
ExecReload = "${pkgs.coreutils}/bin/kill -SIGHUP $MAINPID";
StateDirectory = "vault";
# In `dev` mode vault will put its token here
Environment = lib.optional cfg.dev "HOME=/var/lib/vault";
Owner

À enlever si on supprime le mode dev

À enlever si on supprime le mode dev
ecoppens marked this conversation as resolved
@ -0,0 +48,4 @@
echo "complete -C $out/bin/openbao openbao" > openbao.bash
installShellCompletion openbao.bash
''
+ lib.optionalString stdenv.isLinux ''
Owner

À priori on n'a pas d'aarch64 qui fera tourner ça

À priori on n'a pas d'aarch64 qui fera tourner ça
ecoppens marked this conversation as resolved
@ -0,0 +58,4 @@
}
'';
# passthru.tests = { inherit (nixosTests) vault vault-postgresql vault-dev vault-agent; };
Owner

Inutile visiblement

Inutile visiblement
ecoppens marked this conversation as resolved
ecoppens force-pushed openbao from c9cf7dbbb4 to ded746ff59 2025-03-10 22:28:03 +01:00 Compare
ecoppens force-pushed openbao from ded746ff59 to caa7429644 2025-03-10 22:28:40 +01:00 Compare
ecoppens force-pushed openbao from caa7429644 to 0d328402df 2025-03-10 22:32:01 +01:00 Compare
ecoppens force-pushed openbao from 0d328402df to f8f5478bfb 2025-03-10 22:39:00 +01:00 Compare
ecoppens force-pushed openbao from f8f5478bfb to 302b3a1d45 2025-03-10 22:47:13 +01:00 Compare
ecoppens force-pushed openbao from 302b3a1d45 to 6e1927ccf6 2025-03-10 22:51:10 +01:00 Compare
ecoppens force-pushed openbao from 6e1927ccf6 to 15d5ff68ce 2025-03-10 22:53:27 +01:00 Compare
ecoppens force-pushed openbao from 15d5ff68ce to 3b74da5a1d 2025-03-10 23:06:13 +01:00 Compare
thubrecht requested changes 2025-03-11 08:36:29 +01:00
Dismissed
@ -0,0 +8,4 @@
clusterPort = 3101;
in
{
config = {
Owner

Y'a un config en trop

Y'a un config en trop
ecoppens marked this conversation as resolved
@ -0,0 +14,4 @@
address = "127.0.0.1:${toString port}";
storageBackend = "raft";
listenerExtraConfig = {
Owner

Avec la modification des options ça devient :

settings = {
  listener = {
    tcp.address = "127.0.0.1:${builtins.toString port}";
    cluster_address = "0.0.0.0:${toString clusterPort}";
  };
  
  storage.raft = {
    path = "/var/lib/raft";
    node_id = "raft_storage01"; 
  };
  
  cluster_addr = "http://${host}:${builtins.toString clusterPort}";
  api_addr = "https://${host}";
};
Avec la modification des options ça devient : ```nix settings = { listener = { tcp.address = "127.0.0.1:${builtins.toString port}"; cluster_address = "0.0.0.0:${toString clusterPort}"; }; storage.raft = { path = "/var/lib/raft"; node_id = "raft_storage01"; }; cluster_addr = "http://${host}:${builtins.toString clusterPort}"; api_addr = "https://${host}"; }; ```
ecoppens marked this conversation as resolved
@ -0,0 +24,4 @@
mkPackageOption
getExe'
;
Owner
inherit (lib.types) ...

Avec la liste des types que tu utilises et tu enlèves types. dans la définition des options.

```nix inherit (lib.types) ... ``` Avec la liste des types que tu utilises et tu enlèves `types.` dans la définition des options.
ecoppens marked this conversation as resolved
@ -0,0 +29,4 @@
cfg = config.services.openbao;
jsonFormat = pkgs.formats.json { };
Owner
  settingsFormat = pkgs.formats.json { }; 
```nix settingsFormat = pkgs.formats.json { }; ```
ecoppens marked this conversation as resolved
@ -0,0 +72,4 @@
package = mkPackageOption pkgs "openbao" { };
address = mkOption {
Owner

À remplacer avec l'option settings

À remplacer avec l'option `settings`
ecoppens marked this conversation as resolved
@ -0,0 +121,4 @@
description = "The name of the type of storage backend";
};
storagePath = mkOption {
Owner

Toutes tes options jusque ligne 159 ça se remplace par (et aussi listenerExtraOption):

    settings = mkOption {
      description = ''...'';
      type = submodule {
        freeformType = settingsFormat.type;
        options = {
          listener.tcp.address = mkOption {
            type = str;
            default = "127.0.0.1:8200";
            description = ''
              The address the OpenBao daemon will listen to.
            '';
          };
        };
      };
    };

Et les default sont mis dans la partie config avec des mkDefault c.f. 74ef14eaa0/services/netbird/dashboard.nix (L95)

Toutes tes options jusque ligne 159 ça se remplace par (et aussi `listenerExtraOption`): ```nix settings = mkOption { description = ''...''; type = submodule { freeformType = settingsFormat.type; options = { listener.tcp.address = mkOption { type = str; default = "127.0.0.1:8200"; description = '' The address the OpenBao daemon will listen to. ''; }; }; }; }; ``` Et les default sont mis dans la partie config avec des `mkDefault` c.f. https://git.hubrecht.ovh/hubrecht/nix-modules/src/commit/74ef14eaa0ef0e6fe530639da6cb9be1e46d7b00/services/netbird/dashboard.nix#L95
ecoppens marked this conversation as resolved
@ -0,0 +158,4 @@
description = "Extra text appended to {file}`vault.json`.";
};
extraSettingsPaths = mkOption {
Owner

À supprimer en rajoutant l'option extraArgs.

À supprimer en rajoutant l'option `extraArgs`.
ecoppens marked this conversation as resolved
@ -0,0 +215,4 @@
] ++ optional (config.services.consul.enable && cfg.storageBackend == "consul") "consul.service";
restartIfChanged = false; # do not restart on "nixos-rebuild switch". It would seal the storage and disrupt the clients.
preStart = genJqSecretsReplacementSnippet configFile "/var/lib/openbao/config.json";
Owner
      preStart = genJqSecretsReplacementSnippet (settingsFormat.generate cfg.settings "openbao-settings.json") "/var/lib/openbao/config.json";
```nix preStart = genJqSecretsReplacementSnippet (settingsFormat.generate cfg.settings "openbao-settings.json") "/var/lib/openbao/config.json"; ```
ecoppens marked this conversation as resolved
@ -0,0 +222,4 @@
serviceConfig = {
DynamicUser = true;
ExecStart = escapeSystemdExecArgs [
(lib.getExe cfg.package)
Owner
(getExe cfg.package)

Que tu inherit au début

```nix (getExe cfg.package) ``` Que tu inherit au début
ecoppens marked this conversation as resolved
@ -0,0 +224,4 @@
ExecStart = escapeSystemdExecArgs [
(lib.getExe cfg.package)
"server"
configOptions
Owner
  "-config"
  "/var/lib/openbao/config.json"
] ++ cfg.extraArgs;

Avec :

extraArgs = mkOption {
  type = listOf str;
  default = [ ];
  description = ''
    Extra arguments to pass via the openbao command line.
  '';
};
```nix "-config" "/var/lib/openbao/config.json" ] ++ cfg.extraArgs; ``` Avec : ```nix extraArgs = mkOption { type = listOf str; default = [ ]; description = '' Extra arguments to pass via the openbao command line. ''; }; ```
ecoppens marked this conversation as resolved
@ -0,0 +229,4 @@
ExecReload = "${getExe' pkgs.coreutils "kill"} -SIGHUP $MAINPID";
StateDirectory = "openbao";
UMask = "0700";
# In `dev` mode vault will put its token here
Owner

À supprimer

À supprimer
ecoppens marked this conversation as resolved
@ -37,0 +37,4 @@
# OpenBAO
(local ./nixpkgs/09-init-openbao.patch)
(local ./nixpkgs/10-bump-openbao.patch)
Owner

Comme j'ai dit dans la conv, il faut utiliser npr plutôt:

    #  openbao: init at 2.0.3
    (npr 354366 "sha256-hnGmwmkGeGY6fwZ3L3HSvUX5A5ZpxgslzfmSs1UowdA=")
    #  openbao: 2.1.0 -> 2.1.1
    (npr 375706 "sha256-BQ4O/ub4tivf4cKb7flTpzC7T/4pIQuyEGOwfD12gco=")
Comme j'ai dit dans la conv, il faut utiliser `npr` plutôt: ```nix # openbao: init at 2.0.3 (npr 354366 "sha256-hnGmwmkGeGY6fwZ3L3HSvUX5A5ZpxgslzfmSs1UowdA=") # openbao: 2.1.0 -> 2.1.1 (npr 375706 "sha256-BQ4O/ub4tivf4cKb7flTpzC7T/4pIQuyEGOwfD12gco=") ```
ecoppens marked this conversation as resolved
ecoppens force-pushed openbao from 3b74da5a1d to 0bdb227188 2025-03-11 11:11:03 +01:00 Compare
ecoppens force-pushed openbao from 0bdb227188 to adbbc98d9e 2025-03-11 11:16:08 +01:00 Compare
ecoppens force-pushed openbao from adbbc98d9e to 4f711bc730 2025-03-11 11:18:33 +01:00 Compare
ecoppens force-pushed openbao from 4f711bc730 to a0a229b455 2025-03-11 11:33:30 +01:00 Compare
thubrecht force-pushed openbao from a0a229b455 to a03164240e 2025-03-11 11:56:22 +01:00 Compare
thubrecht scheduled this pull request to auto merge when all checks succeed 2025-03-11 11:56:41 +01:00
thubrecht approved these changes 2025-03-11 12:01:04 +01:00
thubrecht merged commit a03164240e into main 2025-03-11 12:01:05 +01:00
thubrecht deleted branch openbao 2025-03-11 12:01:05 +01:00
Sign in to join this conversation.
No description provided.