mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-11-25 09:36:14 +01:00
Harden blowhole agains sealed Vault
Signed-off-by: Magic_RB <magic_rb@redalder.org>
This commit is contained in:
parent
8b2321dde4
commit
004cfb039b
|
@ -26,8 +26,9 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.hashicorp-consul.unitConfig = {
|
systemd.services."hashicorp-consul" = {
|
||||||
ConditionPathExists = "/run/secrets/consul.json";
|
requires = [ "vault-unsealed.service" ];
|
||||||
|
after = [ "vault-unsealed.service" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
services.hashicorp.consul = {
|
services.hashicorp.consul = {
|
||||||
|
|
|
@ -63,6 +63,30 @@ in
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.services.vault-unsealed = {
|
||||||
|
description = "Check whether the local Vault instance is unsealed and fail if not.";
|
||||||
|
path = with pkgs; [ getent vault ];
|
||||||
|
|
||||||
|
unitConfig = {
|
||||||
|
StartLimitInterval = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
Restart = "always";
|
||||||
|
RestartSec = 30;
|
||||||
|
};
|
||||||
|
|
||||||
|
script = ''
|
||||||
|
export VAULT_ADDR="https://vault.in.redalder.org:8200/"
|
||||||
|
|
||||||
|
while [ $( vault operator key-status |& grep -q "Vault is sealed" ; printf $? ) = 1 ]
|
||||||
|
do
|
||||||
|
sleep 30
|
||||||
|
done
|
||||||
|
exit 2
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
system.stateVersion = "21.05";
|
system.stateVersion = "21.05";
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,8 +31,9 @@ in
|
||||||
destination = "/run/secrets/hostapd_wpa_psk";
|
destination = "/run/secrets/hostapd_wpa_psk";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services.hostapd.unitConfig = {
|
systemd.services."hostapd" = {
|
||||||
ConditionPathExists = "/run/secrets/hostapd_wpa_psk";
|
requires = [ "vault-unsealed.service" ];
|
||||||
|
after = [ "vault-unsealed.service" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
services.hostapd = {
|
services.hostapd = {
|
||||||
|
|
|
@ -45,6 +45,9 @@ in
|
||||||
|
|
||||||
systemd.services."container@klipper" = {
|
systemd.services."container@klipper" = {
|
||||||
restartIfChanged = lib.mkForce false;
|
restartIfChanged = lib.mkForce false;
|
||||||
|
|
||||||
|
requires = [ "vault-unsealed.service" ];
|
||||||
|
after = [ "vault-unsealed.service" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
containers.klipper = {
|
containers.klipper = {
|
||||||
|
|
|
@ -205,6 +205,11 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
systemd.services."hashicorp-envoy-telegraf" = {
|
||||||
|
requires = [ "vault-unsealed.service" ];
|
||||||
|
after = [ "vault-unsealed.service" ];
|
||||||
|
};
|
||||||
|
|
||||||
## There is no way to say, hey, listen on localhost. The listeners option is missing the `address` field
|
## There is no way to say, hey, listen on localhost. The listeners option is missing the `address` field
|
||||||
## and the `name` field so it's impossible to configure....
|
## and the `name` field so it's impossible to configure....
|
||||||
services.hashicorp-envoy.telegraf = {
|
services.hashicorp-envoy.telegraf = {
|
||||||
|
@ -235,6 +240,11 @@ in
|
||||||
extraConsulArgs = [ "-ignore-envoy-compatibility" ];
|
extraConsulArgs = [ "-ignore-envoy-compatibility" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.services."telegraf-magic" = {
|
||||||
|
requires = [ "vault-unsealed.service" ];
|
||||||
|
after = [ "vault-unsealed.service" ];
|
||||||
|
};
|
||||||
|
|
||||||
services.telegraf-magic = {
|
services.telegraf-magic = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
|
@ -324,7 +334,12 @@ in
|
||||||
fsType = "zfs";
|
fsType = "zfs";
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services."container@monitor".serviceConfig.LimitNOFILE = "infinity";
|
systemd.services."container@monitor" = {
|
||||||
|
requires = [ "vault-unsealed.service" ];
|
||||||
|
after = [ "vault-unsealed.service" ];
|
||||||
|
|
||||||
|
serviceConfig.LimitNOFILE = "infinity";
|
||||||
|
};
|
||||||
|
|
||||||
# TODO: split interface name and container name, i.e. rewrite the container module....... again
|
# TODO: split interface name and container name, i.e. rewrite the container module....... again
|
||||||
containers.monitor = {
|
containers.monitor = {
|
||||||
|
|
|
@ -28,6 +28,11 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.services."hashicorp-nomad" = {
|
||||||
|
requires = [ "vault-unsealed.service" ];
|
||||||
|
after = [ "vault-unsealed.service" ];
|
||||||
|
};
|
||||||
|
|
||||||
services.hashicorp.nomad = {
|
services.hashicorp.nomad = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@ in
|
||||||
{
|
{
|
||||||
preStart = "systemd-tmpfiles --create " + config;
|
preStart = "systemd-tmpfiles --create " + config;
|
||||||
postStop = "systemd-tmpfiles --clean " + config;
|
postStop = "systemd-tmpfiles --clean " + config;
|
||||||
|
|
||||||
|
requires = [ "vault-unsealed.service" ];
|
||||||
|
after = [ "vault-unsealed.service" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
services.hashicorp.vault-agent = {
|
services.hashicorp.vault-agent = {
|
||||||
|
|
Loading…
Reference in a new issue