fixup! vault: implement bootstrap integration
Some checks failed
Run nix flake check / flake-check (push) Failing after 6m7s

This commit is contained in:
2026-02-02 22:59:46 +01:00
parent 1f4b7a6cbc
commit 1ae0e67e80
7 changed files with 150 additions and 2 deletions

View File

@@ -366,6 +366,22 @@
sops-nix.nixosModules.sops sops-nix.nixosModules.sops
]; ];
}; };
vaulttest01 = nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs self sops-nix;
};
modules = [
(
{ config, pkgs, ... }:
{
nixpkgs.overlays = commonOverlays;
}
)
./hosts/vaulttest01
sops-nix.nixosModules.sops
];
};
}; };
packages = forAllSystems ( packages = forAllSystems (
{ pkgs }: { pkgs }:

View File

@@ -0,0 +1,110 @@
{
config,
lib,
pkgs,
...
}:
{
imports = [
../template2/hardware-configuration.nix
../../system
../../common/vm
];
nixpkgs.config.allowUnfree = true;
boot.loader.grub.enable = true;
boot.loader.grub.device = "/dev/vda";
networking.hostName = "vaulttest01";
networking.domain = "home.2rjus.net";
networking.useNetworkd = true;
networking.useDHCP = false;
services.resolved.enable = true;
networking.nameservers = [
"10.69.13.5"
"10.69.13.6"
];
systemd.network.enable = true;
systemd.network.networks."ens18" = {
matchConfig.Name = "ens18";
address = [
"10.69.13.150/24"
];
routes = [
{ Gateway = "10.69.13.1"; }
];
linkConfig.RequiredForOnline = "routable";
};
time.timeZone = "Europe/Oslo";
nix.settings.experimental-features = [
"nix-command"
"flakes"
];
nix.settings.tarball-ttl = 0;
environment.systemPackages = with pkgs; [
vim
wget
git
];
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
networking.firewall.enable = false;
# Testing config
# Enable Vault secrets management
vault.enable = true;
# Define a test secret
vault.secrets.test-service = {
secretPath = "hosts/vaulttest01/test-service";
restartTrigger = true;
restartInterval = "daily";
services = [ "vault-test" ];
};
# Create a test service that uses the secret
systemd.services.vault-test = {
description = "Test Vault secret fetching";
wantedBy = [ "multi-user.target" ];
after = [ "vault-secret-test-service.service" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = pkgs.writeShellScript "vault-test" ''
echo "=== Vault Secret Test ==="
echo "Secret path: hosts/vaulttest01/test-service"
if [ -f /run/secrets/test-service/password ]; then
echo " Password file exists"
echo "Password length: $(wc -c < /run/secrets/test-service/password)"
else
echo " Password file missing!"
exit 1
fi
if [ -d /var/lib/vault/cache/test-service ]; then
echo " Cache directory exists"
else
echo " Cache directory missing!"
exit 1
fi
echo "Test successful!"
'';
StandardOutput = "journal+console";
};
};
system.stateVersion = "25.11"; # Did you read the comment?
}

View File

@@ -0,0 +1,5 @@
{ ... }: {
imports = [
./configuration.nix
];
}

View File

@@ -33,7 +33,8 @@ variable "default_target_node" {
variable "default_template_name" { variable "default_template_name" {
description = "Default template VM name to clone from" description = "Default template VM name to clone from"
type = string type = string
default = "nixos-25.11.20260128.fa83fd8" # default = "nixos-25.11.20260128.fa83fd8"
default = "nixos-25.11.20260131.41e21c"
} }
variable "default_ssh_public_key" { variable "default_ssh_public_key" {

View File

@@ -5,6 +5,12 @@
# Each host gets access to its own secrets under hosts/<hostname>/* # Each host gets access to its own secrets under hosts/<hostname>/*
locals { locals {
generated_host_policies = { generated_host_policies = {
"vaulttest01" = {
paths = [
"secret/data/hosts/vaulttest01/*",
]
}
} }
# Placeholder secrets - user should add actual secrets manually or via tofu # Placeholder secrets - user should add actual secrets manually or via tofu

View File

@@ -46,7 +46,11 @@ locals {
auto_generate = true auto_generate = true
password_length = 24 password_length = 24
} }
# TODO: Remove after testing
"hosts/vaulttest01/test-service" = {
auto_generate = true
password_length = 24
}
} }
} }

View File

@@ -45,6 +45,12 @@ locals {
disk_size = "20G" disk_size = "20G"
flake_branch = "vault-setup" # Bootstrap from this branch instead of master flake_branch = "vault-setup" # Bootstrap from this branch instead of master
} }
"vaulttest01" = {
ip = "10.69.13.150/24"
cpu_cores = 2
memory = 2048
disk_size = "20G"
}
} }
# Compute VM configurations with defaults applied # Compute VM configurations with defaults applied