Hello all,
After configuring logrotation for Vault log and audit files, Vault stopped writing to the respective files.
The documentation tells to send a SIGHUP after each rotation, which I tried but Vault service remained ‘dead’. The config reload succeeds though. Is there any extra configuration I shoud be aware of?
Please find below my actual configuration:
- /usr/lib/systemd/system/vault.service
[Unit]
Description="HashiCorp Vault - A tool for managing secrets"
Documentation=https://www.vaultproject.io/docs/
Requires=network-online.target
After=network-online.target
ConditionFileNotEmpty=/etc/vault.d/vault_main.hcl
StartLimitInterval=60
[Service]
User=vault
Group=bin
ProtectSystem=full
ProtectHome=read-only
PrivateTmp=yes
PrivateDevices=yes
SecureBits=keep-caps
Capabilities=CAP_IPC_LOCK+ep
CapabilityBoundingSet=CAP_SYSLOG CAP_IPC_LOCK
NoNewPrivileges=yes
ExecStart=/bin/sh -c 'VAULT_ADDR=${VAULT_ADDR} VAULT_TOKEN=${VAULT_TOKEN} /usr/local/bin/vault server -config=/etc/vault.d/vault_main.hcl -log-level=trace >> /var/log/vault/vault.log 2>&1'
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGINT
Restart=on-failure
RestartSec=5
TimeoutStopSec=30
StartLimitIntervalSec=60
StartLimitBurst=3
LimitNOFILE=524288
LimitNPROC=524288
LimitMEMLOCK=infinity
EnvironmentFile=/home/vault/.creds
[Install]
WantedBy=multi-user.target
- /etc/logrotate.d/vault
/var/log/vault/*.log {
missingok
ifempty
compress # log files will be compressed
dateext
dateformat -%Y%m%d-%s
rotate 20
size 100M
maxsize 100M
create 0664 vault bin
postrotate
/usr/bin/systemctl reload vault 2> /dev/null || true
endscript
}
/var/log/audit/vault_audit.log {
missingok
ifempty
compress # log files will be compressed
dateext
dateformat -%Y%m%d-%s
rotate 20
size 100M
maxsize 100M
create 0664 vault bin
postrotate
/usr/bin/systemctl reload vault 2> /dev/null || true
endscript
}
Thank you for your help!