This cannot possibly be that difficult, but I cannot figure out how to get the hostname value in a consul (really, vault) template.
The basic problem is that I’m trying to use pkiCert
to get a certificate for consul from vault. Since consul needs the certificate before it can talk to the consul server, I can’t use .Node.name
- afaik because consul isn’t up yet. I have to use the hostname if that’s what I want for the cert’s CN when I call vault’s .../issue
Some examples have shown using {{ with $host := env "HOSTNAME" }}
- which seems to just give me an empty value and others have gone to creating custom go functions within the template itself(?), which I’m struggling to comprehend.
{{ with pkiCert "/pki/issue/node-dot-consul" "common_name=1-2-3-4.node.consul" }}
{{ .Data.Cert }}
{{ end }}
Is it possible to replace 1-2-3-4
with a variable of the hostname in that template code?