Шаблон агента хранилища не отображается с отсутствующим сообщением зависимости: vault.write - PullRequest
3 голосов
/ 16 июня 2020

Служба агента хранилища v1.4.2 не может отображать шаблон и создавать файлы при запуске под systemctl.

Но такая же визуализация шаблона работает должным образом с командой, используемой в службе агента хранилища

/opt/vault/bin/vault agent -config /opt/vault/config/default.hcl -log-level=info

Похоже, что OS systemctl не может выполнить команду так, как если бы она выполнялась напрямую.

cat /etc/systemd/system/vault.service
[Unit]
Description=\"HashiCorp Vault Agent\"
Documentation=https://www.vaultproject.io/docs/
Requires=network-online.target
After=network-online.target
ConditionFileNotEmpty=/opt/vault/config/default.hcl
[Service]
User=vault
Group=vault
ProtectSystem=full
ProtectHome=read-only
PrivateTmp=yes
PrivateDevices=yes
SecureBits=keep-caps
AmbientCapabilities=CAP_IPC_LOCK
Capabilities=CAP_IPC_LOCK+ep
CapabilityBoundingSet=CAP_SYSLOG CAP_IPC_LOCK
NoNewPrivileges=yes
ExecStart=/opt/vault/bin/vault agent -config /opt/vault/config/default.hcl -log-level=debug
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGINT
Restart=on-failure
RestartSec=5
TimeoutStopSec=30
StartLimitIntervalSec=60
StartLimitBurst=3
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
journalctl -u vault
  [DEBUG] (runner) running initial templates
 [DEBUG] (runner) initiating run
 [DEBUG] (runner) checking template 749c1d765e84e3e67f9dbb98ec983bf1
 [DEBUG] (runner) missing data for 1 dependencies
 **[DEBUG] (runner) missing dependency: vault.write(pki_int/test/issue/com -> 02a1cc85)**
 [DEBUG] (runner) add used dependency vault.write(pki_int/test/issue/com -> 02a1cc85) to missing since isLeader but do not have a watcher
 [DEBUG] (runner) was not watching 1 dependencies
 [DEBUG] (watcher) adding vault.write(pki_int/test/issue/com -> 02a1cc85)
 [DEBUG] (runner) checking template 43304cf2b8e3710476a7972b03a7544e
 [DEBUG] (runner) missing data for 1 dependencies
 [DEBUG] (runner) missing dependency: vault.write(pki_int/test/issue/com -> 02a1cc85)
 [DEBUG] (runner) missing data for 1 dependencies
 [DEBUG] (runner) checking template ca2b67db58c83f0e184663098bcb74b8
 [DEBUG] (runner) rendering "(dynamic)" => "/tmp/abc.test"
 [INFO] (runner) rendered "(dynamic)" => "/tmp/abc.test"
 [DEBUG] (runner) diffing and updating dependencies
 [DEBUG] (runner) watching 1 dependencies
 [INFO]  auth.handler: renewed auth token
 [DEBUG] Found certificate and set lease duration to 150 seconds
 [DEBUG] (runner) receiving dependency vault.write(pki_int/test/issue/com -> 02a1cc85)
 [DEBUG] (runner) initiating run
 [DEBUG] (runner) checking template 749c1d765e84e3e67f9dbb98ec983bf1
 [DEBUG] (runner) rendering "/opt/vault/templates/test.cert.tpl" => "/tmp/test.cert.pem"
 [INFO] (runner) rendered "/opt/vault/templates/test.cert.tpl" => "/tmp/test.cert.pem"
 [DEBUG] (runner) checking template 43304cf2b8e3710476a7972b03a7544e
 [DEBUG] (runner) rendering "/opt/vault/templates/test.key.tpl" => "/tmp/test.key.pem"
 [INFO] (runner) rendered "/opt/vault/templates/test.key.tpl" => "/tmp/test.key.pem"
 [DEBUG] (runner) checking template ca2b67db58c83f0e184663098bcb74b8
 [DEBUG] (runner) rendering "(dynamic)" => "/tmp/abc.test"
 [DEBUG] (runner) diffing and updating dependencies
 [DEBUG] (runner) vault.write(pki_int/test/issue/com -> 02a1cc85) is still needed
 [DEBUG] (runner) watching 1 dependencies
 [DEBUG] (runner) all templates rendered

Шаблоны

test-cert.tpl
{{- /* test.abc.com.cert.tpl */ -}}
{{ with secret "pki_int/test/issue/abc.com" "common_name=test.abc.com" "ttl=2m" }}
{{ .Data.certificate }}
{{ .Data.issuing_ca }}{{ end }}

test-key.tpl
{{ with secret "pki_int/test/issue/abc.com" "common_name=test.abc.com" "ttl=2m" }}
{{ .Data.private_key }}{{ end }}
{{- /* test.abc.com.key.tpl */ -}}

test.tpl
{{ with secret "pki_int/test/issue/abc.com" "common_name=test.abc.com" "ttl=2m" }}
{{ .Data.private_key }}{{ end }}
abc123
To Reproduce
Steps to reproduce the behavior:

Run systemctl restart vault
Run journalctl -u vault
See error
Expected behavior
I expected it to create the following files with certs

/tmp/test.cert.pem
/tmp/test.key.pem
/tmp/abc.test"

Среда:

Версия сервера хранилища (получение со статусом хранилища): 1.4.2

Версия интерфейса командной строки хранилища (получение с версией хранилища): v1.4.2

Работа сервера Система / Архитектура: Red Hat Enterprise Linux Серверный выпуск 7.8 (Maipo)]

Файл (ы) конфигурации агента хранилища:

cat /opt/vault/config/default.hcl
pid_file   = "/opt/vault/data/vault-pid"
vault {
  address = "https://xxxxxxxxx:443"
}
auto_auth {
  method "aws" {
    mount_path = "auth/aws"
    config = {
      type = "iam"
      role = "test-iam-role"
    }
  }
  sink "file" {
    config = {
      path = "/opt/vault/data/vault-token"
    }
  }
}
template {
  source      = "/opt/vault/templates/test.cert.tpl"
  destination = "/tmp/test.cert.pem"
  perms       = "0600"
}

template {
  source      = "/opt/vault/templates/test.key.tpl"
  destination = "/tmp/test.key.pem"
  perms       = "0600"
}

template {
  contents     = "testabc"
  destination = "/tmp/abc.test"
}

Дополнительный контекст

У меня есть замаскируйте данные, чтобы удалить ссылку на исходный домен, поэтому примите во внимание это, если есть какие-либо несоответствия.

1 Ответ

0 голосов
/ 10 июля 2020

Мне удается решить эту проблему, изменив расположение файлов сертификатов с '/ tmp' на '/ opt / vault / certs', и проблема решена.

...