如何从consul模板中仅查询密钥的值?从保险库cli我会做
vault read -field=value secret/somekey
它工作正常。但是,在consul-template
中{{secret "secret/somekey"}}
返回类似
的内容{ 2592000 false map[value:11122222001040]
我可以看到它输出lease_duration等以及值。我如何获得consul-template中的值?
答案 0 :(得分:1)
In your template you will need to use:
{{with secret "secret/somekey"}}{{.Data.value}}{{end}}
In your config file you will also need a section for vault:
vault {
address = "https://vault.service.consul:8200"
token = "abcd1234"
}
or you could use the VAULT_TOKEN
environment variable.