-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
template{} don't have access to nomad task environment (and interpolation keys) #1979
Comments
Is this going to be available in an upcoming 0.5.x release? It is a key missing link to be able to source environment agnostic templates as task artifacts as there is no way to tell the template engine from which environment store to source the template replacements. |
@momania they are working on this as we speak, its a pretty big change internally to how template{} and consul-template works - there is afaik no official stance on 0.5 or 0.6 will be the release to include this improvement :) |
@momania As @jippi mentioned it is being worked on right now! This is part of a reliability/refactor work happening and at the end of that the code base will allow us to pass env vars to consul-template. So it is a matter of when it gets done and what release we are on. I am optimistic that it will be in a 0.5.x cut! |
That's great news! Thanks! |
If I understand correclty, this should work now, correct? If so, can someone please provide an example of calling a nomad interpolation key. I have tried using something like Hostname = server-${NOMAD_ALLOC_INDEX} and hostname = server-{{env "NOMAD_ALLOC_INDEX"}}, but when running either through consul-template I either get the literal text printed back (using ${KEY}) or nothing (using {{env "KEY"}}. Buy nothing I mean consul-tempalte returns server- . |
https://www.nomadproject.io/docs/job-specification/template.html got that covered? spoiler: |
Wow... big derp on my part, I glossed right over that part of the docs.
|
I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues. |
I've discussed this a few times with @dadgar , but couldn't find any ticket on the issue, so creating one.
Today the
template{}
environment do not got access to any of the nomad interpolation values like${NOMAD_ALLOC_INDEX}
or${NOMAD_PORT_label}
, which for me - and many others based on the gitter activity - is both surprising and severely limiting the usefulness and ease of setting up in-container configuration without this nomad context.I would expect accessing these keys would be
{{env "NOMAD_ALLOC_INDEX"}}
as per the usual CT docs on env accessI'm fully aware @dadgar wanted this in 0.5.0, but due to the complexity of the task, it didn't make it, so here's hoping for the feature getting into 0.5.1.
The technical issue, as far as I understand, is that consul-template, embedded in nomad, does not support injecting of arbitrary ENV keys programatically yet.
I assume consul-template logic would be expanded to take a dictionary of env() to the runner and have https://github.com/hashicorp/consul-template/blob/4836d07af372ff9f705a5013dfc534f110621223/template/template_functions.go#L467-L470 look up in that dictionary as well?
The text was updated successfully, but these errors were encountered: