[Unit]
Description="HashiCorp Vault - A tool for managing secrets"
Documentation=https://www.vaultproject.io/docs/
Requires=network-online.target
After=network-online.target
ConditionFileNotEmpty={{ vault_root_dir }}/etc/vault.hcl
StartLimitIntervalSec=60
StartLimitBurst=3

# Vault version {{ vault_current_version }}
[Service]
Type=notify
User={{ vault_user }}
Group={{ vault_user }}
ProtectSystem=full
ProtectHome=read-only
PrivateTmp=yes
PrivateDevices=yes
SecureBits=keep-caps
AmbientCapabilities=CAP_IPC_LOCK CAP_NET_BIND_SERVICE
CapabilityBoundingSet=CAP_SYSLOG CAP_IPC_LOCK CAP_NET_BIND_SERVICE
NoNewPrivileges=yes
ExecStart=/usr/local/bin/vault server -config={{ vault_root_dir }}/etc/
ExecReload=/bin/kill --signal HUP $MAINPID
{%- if vault_unseal_keys | length > 0 +%}
ExecStartPost=!{{ vault_root_dir }}/bin/unseal }}
{%- endif +%}
KillMode=process
KillSignal=SIGINT
Restart=on-failure
RestartSec=5
StartLimitInterval=0
TimeoutStopSec=30
LimitNOFILE=65536
LimitMEMLOCK=infinity
OOMScoreAdjust=-500

[Install]
WantedBy=multi-user.target

