使用模板启动 Vault Agent:
vault agent -config=templates/config.hcl -log-level=debug
失败并出现以下错误:
[错误] auth.handler:从方法获取路径或数据时出错:error="no known secret ID" backoff=2.438818298
重现问题的步骤:
政策:
path "my-app/data/testsecret/*" {
capabilities = ["create", "update", "read"]
}
path "my-app/metadata/testsecret/*" {
capabilities = ["list"]
}
客户端配置:
pid_file = "./pidfile"
vault {
address = "http://XX.XX.XX.XX:XXXX"
}
auto_auth {
method {
type = "approle"
config = {
role_id_file_path = "templates/roleid"
secret_id_file_path = "templates/secretid"
}
}
sink {
type = "file"
config = {
path = "templates/file-foo"
}
}
}
template {
source = "templates/template.ctmpl"
destination = "templates/render.txt"
}
模板.ctmpl:
{{ with secret "my-app/data/testsecret" }}
passwd: {{ .Data.data.passwd }}
{{ end }}
我认为秘密是存在的:
$ vault kv get my-app/testsecret
====== Metadata ======
Key Value
--- -----
created_time 2020-10-22T07:18:48.205108671Z
deletion_time n/a
destroyed false
version 6
===== Data =====
Key Value
--- -----
passwd cat
秘诀是kv v2:
$ vault secrets list --detailed |grep my-app
my-app/ kv kv_5898e685 system system false replicated false false map[version:2] n/a cd436e93-db3b-c317-1c31-6967c7b25764