Files
nixpkgs/nixos/tests/vault-agent.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

62 lines
1.4 KiB
Nix

{ pkgs, ... }:
{
name = "vault-agent";
nodes.machine =
{ config, pkgs, ... }:
{
services.vault-agent.instances.example.settings = {
vault.address = config.environment.variables.VAULT_ADDR;
auto_auth = [
{
method = [
{
type = "token_file";
config.token_file_path = pkgs.writeText "vault-token" config.environment.variables.VAULT_TOKEN;
}
];
}
];
template = [
{
contents = ''
{{- with secret "secret/example" }}
{{ .Data.data.key }}"
{{- end }}
'';
perms = "0600";
destination = "/example";
}
];
};
services.vault = {
enable = true;
dev = true;
devRootTokenID = config.environment.variables.VAULT_TOKEN;
};
environment = {
systemPackages = [ pkgs.vault ];
variables = {
VAULT_ADDR = "http://localhost:8200";
VAULT_TOKEN = "root";
};
};
};
testScript = ''
machine.wait_for_unit("vault.service")
machine.wait_for_open_port(8200)
machine.wait_until_succeeds('vault kv put secret/example key=example')
machine.wait_for_unit("vault-agent-example.service")
machine.wait_for_file("/example")
machine.succeed('grep "example" /example')
'';
}