blob: dc86c829b67af9e5bd4148bb853847aaeeb0dd7c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import ./make-test-python.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')
'';
})
|