mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 03:17:13 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
77 lines
2.5 KiB
Nix
77 lines
2.5 KiB
Nix
/*
|
|
This test checks that
|
|
- multiple config files can be loaded
|
|
- the storage backend can be in a file outside the nix store
|
|
as is required for security (required because while confidentiality is
|
|
always covered, availability isn't)
|
|
- the postgres integration works
|
|
*/
|
|
import ./make-test-python.nix (
|
|
{ pkgs, ... }:
|
|
{
|
|
name = "vault-postgresql";
|
|
meta = with pkgs.lib.maintainers; {
|
|
maintainers = [
|
|
lnl7
|
|
roberth
|
|
];
|
|
};
|
|
nodes.machine =
|
|
{ lib, pkgs, ... }:
|
|
{
|
|
environment.systemPackages = [ pkgs.vault ];
|
|
environment.variables.VAULT_ADDR = "http://127.0.0.1:8200";
|
|
services.vault.enable = true;
|
|
services.vault.extraSettingsPaths = [ "/run/vault.hcl" ];
|
|
|
|
systemd.services.vault = {
|
|
after = [
|
|
"postgresql.service"
|
|
];
|
|
# Try for about 10 minutes rather than the default of 5 attempts.
|
|
serviceConfig.RestartSec = 1;
|
|
serviceConfig.StartLimitBurst = 600;
|
|
};
|
|
# systemd.services.vault.unitConfig.RequiresMountsFor = "/run/keys/";
|
|
|
|
services.postgresql.enable = true;
|
|
services.postgresql.initialScript = pkgs.writeText "init.psql" ''
|
|
CREATE USER vaultuser WITH ENCRYPTED PASSWORD 'thisisthepass';
|
|
GRANT CONNECT ON DATABASE postgres TO vaultuser;
|
|
|
|
-- https://www.vaultproject.io/docs/configuration/storage/postgresql
|
|
CREATE TABLE vault_kv_store (
|
|
parent_path TEXT COLLATE "C" NOT NULL,
|
|
path TEXT COLLATE "C",
|
|
key TEXT COLLATE "C",
|
|
value BYTEA,
|
|
CONSTRAINT pkey PRIMARY KEY (path, key)
|
|
);
|
|
CREATE INDEX parent_path_idx ON vault_kv_store (parent_path);
|
|
|
|
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO vaultuser;
|
|
'';
|
|
};
|
|
|
|
testScript = ''
|
|
secretConfig = """
|
|
storage "postgresql" {
|
|
connection_url = "postgres://vaultuser:thisisthepass@localhost/postgres?sslmode=disable"
|
|
}
|
|
"""
|
|
|
|
start_all()
|
|
|
|
machine.wait_for_unit("multi-user.target")
|
|
machine.succeed("cat >/root/vault.hcl <<EOF\n%s\nEOF\n" % secretConfig)
|
|
machine.succeed(
|
|
"install --owner vault --mode 0400 /root/vault.hcl /run/vault.hcl; rm /root/vault.hcl"
|
|
)
|
|
machine.wait_for_unit("vault.service")
|
|
machine.wait_for_open_port(8200)
|
|
machine.succeed("vault operator init")
|
|
machine.succeed("vault status || test $? -eq 2")
|
|
'';
|
|
}
|
|
)
|