consul-template having problems with dash/hyphen in vault key name

2,320 views
Skip to first unread message

Jonathan Duncan

unread,
May 19, 2017, 5:25:47 PM5/19/17
to Consul
Can consul-template not handle vault key names with a dash/hyphen in them?

I had some keys in my vault that had dashes in them:

template {
    destination = "/tmp/test.value"
    perms = 0640
    contents = <<EOF
{{with secret "secret/secret-test-1"}}{{.Data.some-key}}{{end}}
{{with secret "secret/secret-test-1"}}{{.Data.longer-key-name}}{{end}}
EOF
}

I would start my consul-template service and get errors:

consul-template: Consul Template returned errors:
consul-template: (dynamic): parse: template: :1: bad character U+002D '-'
systemd: consul-template.service: Main process exited, code=exited, status=14/n/a
systemd: consul-template.service: Unit entered failed state.

I changed the dashes to underscores in the key names, started consul-template again, and it worked fine.

template {
    destination = "/tmp/test.value"
    perms = 0640
    contents = <<EOF
{{with secret "secret/secret-test-1"}}{{.Data.some_key}}{{end}}
{{with secret "secret/secret-test-1"}}{{.Data.longer_key_name}}{{end}}
EOF
}

Did I find a bug? Or is this a known naming convention that is not mentioned in the documentation?

Thanks

James Phillips

unread,
May 31, 2017, 4:46:54 PM5/31/17
to consu...@googlegroups.com
.Hi,

This looks like a limitation of the Go template engine, unfortunately,
and would need to be fixed upstream. I think the built-in "index"
function will let you get at these -
https://stackoverflow.com/a/24629884/7497653.

-- James
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in violation
> of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/hashicorp/consul/issues
> IRC: #consul on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Consul" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to consul-tool...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/consul-tool/78f7f1a4-fd98-4cd0-8034-2315890319fd%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages